v8-compile-cache
v8-compile-cache copied to clipboard
Newer V8 code caching features
Very interesting project. I think you can benefit from some of the newer features we added to code caching in V8.
The current API compiles the top-level code and immediately puts that compilation result into the code cache. Inner functions are compiled lazily and not included in the cache. We recently introduced a new compile option that forces V8 to compile every function in the source so that we end up with more data in the code cache.
We also introduced a new API to produce the code cache not immediately after compilation, but at a later point when some execution might already have happened, at which point we may have compiled more functions.
I know none of this are yet available in Node.js since the newest V8 has not rolled into Node.js yet, and even then you have to expose these new API in a suitable way.
But I thought this might interest you in the long run.
@hashseed Any updates on if or when these things might make it into Node?
This new API I mentioned here should be in Node.js once it upgrades to V8 6.5. It might need to be exposed via vm module to become easily accessible though.
Is it available now we have Node 10?
It's getting there, but not quite in Node 10 yet. Maybe we'll still get it before the Node 10 LTS ship sails :)
https://github.com/nodejs/node/issues/20052
We recently introduced a new compile option that forces V8 to compile every function in the source so that we end up with more data in the code cache.
@hashseed I think this isn't in Node yet, do you happen to know if there are plans to expose it? I've looked at createCachedData
but sadly it doesn't seem to include the option to force compilation, unless I'm missing something?
This is already in Node 10.6.0 and above. We should attempt to fix this. https://nodejs.org/api/vm.html#vm_script_createcacheddata
Here is an example: https://github.com/vercel/ncc/pull/112 by @guybedford