-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Enable bytecode caching to reduce time cost on require() #45106
Comments
On-disk code caching has been discussed in the past. One problem is that the bytecode (and code caching in general) is specific to the V8 version and V8 command line flags, possibly even the machine it's running on. For example, it's unspecified what happens when V8 doesn't really guard against mismatches either so if you get it wrong, things are likely to go boom in unpredictable ways. Another problem is that creating the code cache is relatively slow, it's essentially object serialization. It's definitely going to regress cold boots (first-time run, nothing cached) so the wins for warm boots should be substantial to make up for that. Needs careful benchmarking. |
https://nodejs.org/dist/latest-v19.x/docs/api/cli.html#--build-snapshot |
Thank you! |
Web snapshots may also make it more tractable if/when it stabilizes (still gated behind |
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
I'll make a comment to keep this open. Based on what I've seen in node 20, some of the ground work is being done that makes this possible for userland code and maybe is already done. IIRC, I had seen @joyeecheung doing God's work |
I'll close this as it's largely a duplicate of #47472. That issue is younger but has a lot more discussion. |
What is the problem this feature will solve?
When discussing the CSP FaaS teams, the top concern is the start up time of their FaaS framework. The framework is usually programmed by JS and contains only a few lines of require(), e.g.
require("FC_core"); require("FC_meter");require("payment");
.In real world measurement, the framework usually takes hundreds of millionsecond to start up. Majority time is spent on parsing and compiling hundred of modules during require().
What is the feature you are proposing to solve the problem?
Enable byte code caching in the first run and serialize the cache onto disk, and deserialize the byte code caching in following runs. It will be enabled by runtime parameters and by default disabled due to hurt memory usage.
I'm asking whether it will be an accepted method.
What alternatives have you considered?
No response
The text was updated successfully, but these errors were encountered: