Skip to content
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

Newer V8 code caching features #6

Open
hashseed opened this issue Dec 6, 2017 · 6 comments
Open

Newer V8 code caching features #6

hashseed opened this issue Dec 6, 2017 · 6 comments

Comments

@hashseed
Copy link

hashseed commented Dec 6, 2017

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.

@jdalton
Copy link

jdalton commented Feb 10, 2018

@hashseed Any updates on if or when these things might make it into Node?

@hashseed
Copy link
Author

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.

@robpalme
Copy link

Is it available now we have Node 10?

@hashseed
Copy link
Author

It's getting there, but not quite in Node 10 yet. Maybe we'll still get it before the Node 10 LTS ship sails :)

nodejs/node#20052

@jscheid
Copy link

jscheid commented Oct 15, 2018

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?

@aminya
Copy link

aminya commented Sep 29, 2020

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: vercel/ncc#112 by @guybedford

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants