Reputation: 8056
I intend to run node somefile.js
multiple times.
Presumably each time I execute this file with Node, it will JIT-compile the script and perform other optimizations.
Sadly: each time execution finishes, it will forget all the work it did.
Is there any way for me to retain from a previous run the optimizations that V8 has produced, and apply them to a subsequent run?
Upvotes: 4
Views: 1428
Reputation: 2162
Saving/loading of compiled code for v8 is complicated and rarely justifiable because there is much more information to be saved than bare compiled code and because it takes v8 little time to optimize and compile (well, there's also warm-up, but still overall time before execution of optimized code is rarely that big).
So there is no thing you are asking for in mainline v8.
You can however supply --always-opt
option to v8 and also there's a way to force a particular function to be optimized on next call. You should only do that if your function is stable.
Upvotes: 4