-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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 Node.js/v8 compile caching via entrypoint shims #59720
Conversation
nodejs/node#54501 was merged into Node, so this API should end up available in a later version. I've marked this PR as ready for review, if we want to think about whether or not it's worth the extra shim / indirection. |
let output = options.output; | ||
if (options.enableCompileCache) { | ||
const originalOutput = output; | ||
output = path.join(path.dirname(output), "_" + path.basename(output)); |
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.
This was just an expedient name choice; I can also remove the extension and then make it like tsc_.js
which may sort better.
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 was going to say that _tsc
tab-completes better on the command-line, though, because it doesn't interfere with types<TAB>
-- but there's so much stuff in built/local that it doesn't actually make a difference.
@typescript-bot test startup-only [email protected],[email protected] |
@typescript-bot perf test startup-only [email protected],[email protected] |
Starting jobs; this comment will be updated as builds start and complete.
|
@jakebailey Here they are:
startupComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
As a note to self, if/when we switch to ESM when const { createRequire, enableCompileCache } = process.getBuiltinModule("node:module");
enableCompileCache();
createRequire(import.meta.url)("./_tsc.js"); |
let output = options.output; | ||
if (options.enableCompileCache) { | ||
const originalOutput = output; | ||
output = path.join(path.dirname(output), "_" + path.basename(output)); |
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 was going to say that _tsc
tab-completes better on the command-line, though, because it doesn't interfere with types<TAB>
-- but there's so much stuff in built/local that it doesn't actually make a difference.
@typescript-bot perf test this faster [email protected],[email protected] |
Starting jobs; this comment will be updated as builds start and complete.
|
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
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.
nice
This makes use of nodejs/node#54501 by converting our larger entrypoints (
tsc
,tsserver
,typingsInstaller
) into shims which callrequire("node:module").enableCompileCache()
, thenrequire
the actual code. Our entrypoints are assumed to always be run in Node (or a compatible runtime), so this is safe.This gives roughly a 2.5x startup time boost.
Gotchas:
_tsc.js
,_tsserver.js
,_typingsInstaller.js