Hot-Loading Best Practice?


#1

What is the best practice for hot-loading in Chai?

I have a a situation where I might have some instances of Chai scripts running, and the file is edited and reloaded. I would like to keep any current instances running (if possible) while new instances use the new version.

Is it feasible to run each instance in its own state? Would that cause issues with the number of scripts.


#2

I would personally aim for one ChaiScript instance per script, based on what you said - but the question is: how many simultaneous instances are you talking about?

The only concern will be memory usage, and I’ve never really tried to see how memory usage scales with many ChaiScript instances running at once. Otherwise there should be no problem.

-Jaosn


#3

Not 100% on how many right now. But a safe bet would be around 75-100 instances. certainly seems like the easist way to do it.


#5

I’m trying to follow this pattern, but identifying files dependent on a script is complicated by the use statement. I looked briefly at the implementation of use in chaiscript_engine, wondering if I might find a path resolution hook or some other callback, and I found none.

I’ve resorted to parsing the source code with a regex looking for use. Is there a better approach?


#6

I could probably implement my own Chai use function that calls out to C++.


#7

The best that ChaiScript offers is the ability to set the “use” search paths, which are set via the constructor https://codedocs.xyz/ChaiScript/ChaiScript/classchaiscript_1_1ChaiScript.html