-
-
Notifications
You must be signed in to change notification settings - Fork 567
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
Improve engine creation performance #615
Comments
@lahma what is your thought on that? |
That sounds reasonable. There's the immutable property descriptor already for undfined, but it suffers slight performance penalty of having the CustomValue flag set that directs to virtual call. IIRC descriptors are created as new instances when re-configured, hopefully there are no pitfalls. I've only profiled the run time of initialized engine so this is a path I've not set my foot on 🙂 |
PR #625 |
You are mentioning descriptors, but I was thinking about reusing the ClrFunctionInsrance instances inside them as static. These won't be accessed or changed. |
The problem with static |
Having the engine be part of the state being an issue in some cases, this could be solved by passing a "context" as arguments where it makes sense. This would probably be the engine itself of something that contains it plus some other local information (like steps, debug info, ...) |
Talking about performance, I wonder:
So, I did an initial perf test, pretty awesome speed on my Surface Book 2 (i7 + 16GB), I am impressed: Direct: 37,425 times / sec Basically the cached version is roughly 15 times faster than the one that parses every time. With the following test codes:
The randomized 2nd parameter ( |
Can you share us the actual caching logic? It can be a slippery slope to find a caching logic that works with variable input. |
@lahma it is not really a native cache mechanism per say. I use DynamicExpresso (https://github.com/davideicardi/DynamicExpresso) in a project to do expression evaluation, and For Jint, the cache I mentioned it is nothing but just not running |
While doing some memory profiling I found that the main cost was during the initialization of the constructor objects when we create many
ClrFunctionInstance
andPropertyDescriptor
instances like here:https://github.com/sebastienros/jint/blob/dev/Jint/Native/Date/DateConstructor.cs#L77
I assume these objects should be immutable (they can still be replaced) and we should be able to mark them static and reuse them.
Snapshot of 50 requests in Orchard Core:
The text was updated successfully, but these errors were encountered: