-
-
Notifications
You must be signed in to change notification settings - Fork 564
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is an object pool suggested for speed performance? #695
Comments
There was some work done earlier to make engine instantiation faster, #625 . Engine will of course load features on demand so if you urilize all JS constructs the engine needs to initialize them lazily. Caching the parsed program helps too. Sharing engine has the problem of old global state. |
@lahma what is your opinion about being able to mark an ObjectInstance immutable, such that we would not be able to change the builtin constructors, or mark pre-defined properties as not configurable. This way we could just re-initalize the lexical environments and reuse the engines. The main benefit would be that these built-in elements wouldn't have to be re-created. It doesn't seem very hard to do, at least for the most obvious properties and constructor objects. Also it should be easy to cover everything as it would mean anything that has a property name currently in the engine code. Forgive me if that's something I have already asked somewhere else ;) |
I'm not against the idea, just a bit afraid of the complexity that might be involved with this freezing. I don't know if there's a cut-off point where we could declare engine fast to create and that wouldn't matter too much? My gut feeling is that engine creation is now quite fast, but initializing the state into engine is the problem. Say that you want to include couple MB of your support scripts - most of the time will be spent parsing and preparing. So might the actual requirement be to be able to inject start state faster into engine? Or if you mean these startup scripts as built-in elements then this would rhyme with what you expressed. This is also somewhat related to #665 , #491 and #673 Of course we can always try to make engine creation even faster 🙂 And I want to end with a JS rant when I was thinking about inlining some known functions for performance:
This is why we can't have nice things 😠 |
I can see these two levels of reusability:
Maybe the second option is also the way to implement option 1. Though freezing a state (default engine state) is even faster for perf than having to clone a snapshot (allocations). |
But yeah, option 1 means we would disallow things like |
@rushfrisby I'm working on PR #789 , you might want to follow that development and please chime in if it's missing something. |
Immutables is a nice solution to this. Keep a shared Math instance until you change it, then it becomes a new instance dedicated for that engine. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
With some other javascript engines I found that instantiating the engine was very expensive and to combat this I created an object pool of engines. Would you suggest this approach for Jint as well or is creating an engine lightweight enough that it isn't needed?
The text was updated successfully, but these errors were encountered: