-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
build: tracking issue for V8 code cache intergration #21563
Comments
BTW: I explored the idea of generating the code cache after the script has been run and it does not seem to make much difference: See benchmark results
|
As a sanity check, does the code cache size change significantly if you create it after the script has been run? How many functions do you see lazily compiled with both variants (creating cache data before and after execution) with |
Also, I don't think you need |
@joyeecheung when the files that node_js2c depends on change the makefile should run it again automatically right? |
@devsnek It is supposed to. It doesn't (that's in the TODO list in the OP, feel free to pick it up). |
This patch makes it possible to generate the code cache for the builtins directly from the original script object (instead of compiling a new one) and after the script has been run (via `NativeModule.require`). Before this patch only the top level functions (the wrapped ones) are included in the cache, after this patch the inner functions in those modules will be included as well. Also blacklists modules from dependencies like V8 and node-inspect since we cannot guarantee that they are suitable to be executed directly. PR-URL: #21567 Refs: #21563 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This patch makes it possible to generate the code cache for the builtins directly from the original script object (instead of compiling a new one) and after the script has been run (via `NativeModule.require`). Before this patch only the top level functions (the wrapped ones) are included in the cache, after this patch the inner functions in those modules will be included as well. Also blacklists modules from dependencies like V8 and node-inspect since we cannot guarantee that they are suitable to be executed directly. PR-URL: #21567 Refs: #21563 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
A few notes on better hash checks of the code cache: in theory it should be possible to make sure |
e7f710c broke the code cache generation since internalBinding is now passed in through the wrapper and cannot be redeclared. This patch fixes that. Refs: #21563 PR-URL: #23855 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Add the code cache tests to the default test suite, and test the bookkeeping when the binary is not built with the code cache. - Test the code cache generator to make sure we do not accidentally break it - until we enable code cache in the CI. Refs: #21563 PR-URL: #23855 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
e7f710c broke the code cache generation since internalBinding is now passed in through the wrapper and cannot be redeclared. This patch fixes that. Refs: #21563 PR-URL: #23855 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Add the code cache tests to the default test suite, and test the bookkeeping when the binary is not built with the code cache. - Test the code cache generator to make sure we do not accidentally break it - until we enable code cache in the CI. Refs: #21563 PR-URL: #23855 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
e7f710c broke the code cache generation since internalBinding is now passed in through the wrapper and cannot be redeclared. This patch fixes that. Refs: #21563 PR-URL: #23855 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Add the code cache tests to the default test suite, and test the bookkeeping when the binary is not built with the code cache. - Test the code cache generator to make sure we do not accidentally break it - until we enable code cache in the CI. Refs: #21563 PR-URL: #23855 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
e7f710c broke the code cache generation since internalBinding is now passed in through the wrapper and cannot be redeclared. This patch fixes that. Refs: #21563 PR-URL: #23855 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Add the code cache tests to the default test suite, and test the bookkeeping when the binary is not built with the code cache. - Test the code cache generator to make sure we do not accidentally break it - until we enable code cache in the CI. Refs: #21563 PR-URL: #23855 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
e7f710c broke the code cache generation since internalBinding is now passed in through the wrapper and cannot be redeclared. This patch fixes that. Refs: #21563 PR-URL: #23855 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Add the code cache tests to the default test suite, and test the bookkeeping when the binary is not built with the code cache. - Test the code cache generator to make sure we do not accidentally break it - until we enable code cache in the CI. Refs: #21563 PR-URL: #23855 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Anything to update here? @joyeecheung It's been quiet for a while but I don't know if that means nothing relevant is happening or if it means it just isn't being updated. :-D |
@Trott The changes I've been making to |
Fixed in #27161 |
Following up on #21405
Better integrity check when using the code cache insimply relying on V8 to do the checks is fineNativeModule.prototype.compile
(right nowSerializedCodeData::SourceHash
returnssource->length()
) e.g. calculating the checksums of the source code in both js2c and the code cache generator and compare them before using the cache. See build: speed up startup with V8 code cache #21405 (comment)script.createCachedData
to generate the code cache after the builtin modules haverunInThisContext()
, so that the cache of the lazily compiled inner functions are also included (right now only the top level function is included in the cache),see build: speed up startup with V8 code cache #21405 (comment) . We may need to include the code cache generator in core or expose the scripts to user land.internal/bootstrap/loaders.js
andinternal/bootstrap/node.js
(these two are compiled in C++): src: use NativeModuleLoader to compile all the bootstrappers #24775(might be related if we still use JS to generate the cache) Add support for the full range ofit's not using the JS land function anymoreCompileOptions
(and possiblyNoCacheReason
) toContextifyScript
/vm.Script
Long-term action items
node.js
and/ornode.cc
so that we can create something like amkcodecache
(similar tomksnapshot
) target instead of generating the code cache with a user-land JS script tools: implement mkcodecache as an executable #27135node_js2c
is modified, the cache will be regenerated and compiled the next time Node.js is built withnode_code_cache_path
build,tools: use mkcodecache to add code cache to the binaries #27161test-code-cache
is run in the release CI to make sure we don't have a ~100% performance regression of startup time:build: build release/CI on non-Windows with code cache #22934build,tools: use mkcodecache to add code cache to the binaries #27161The text was updated successfully, but these errors were encountered: