-
Notifications
You must be signed in to change notification settings - Fork 171
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
perf: prefer module.enableCompileCache
over v8-compile-cache
#574
base: main
Are you sure you want to change the base?
Conversation
// @ts-expect-error - Missing types | ||
if (!Module.enableCompileCache) { | ||
// Node.js segfaults when using npm@>=9.7.0 and v8-compile-cache | ||
// $ docker run -it node:20.3.0-slim corepack [email protected] --version | ||
// [SIGSEGV] | ||
if (locator.name !== `npm` || semverLt(locator.reference, `9.7.0`)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we can minimize the diff, to avoid cluttering git blame
// @ts-expect-error - Missing types | |
if (!Module.enableCompileCache) { | |
// Node.js segfaults when using npm@>=9.7.0 and v8-compile-cache | |
// $ docker run -it node:20.3.0-slim corepack npm@9.7.1 --version | |
// [SIGSEGV] | |
if (locator.name !== `npm` || semverLt(locator.reference, `9.7.0`)) { | |
// Node.js segfaults when using npm@>=9.7.0 and v8-compile-cache | |
// $ docker run -it node:20.3.0-slim corepack [email protected] --version | |
// [SIGSEGV] | |
if (locator.name !== `npm` || semverLt(locator.reference, `9.7.0`)) { | |
// @ts-expect-error - Missing types | |
if (!Module.enableCompileCache) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't benchmarked it but this would cause it to do work it doesn't have to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only for npm though, and if native support is disabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would always affect npm as it has to check the version first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's what I'm saying, and if native support is indeed disabled – otherwise it would have to do the check anyway
Node.js has added a built-in compile cache so this PR changes the code to prefer that over
v8-compile-cache
.https://nodejs.org/docs/v22.11.0/api/module.html#moduleenablecompilecachecachedir
Fixes #342
Closes #573 (supersedes it)
Results