Enable Node.js/v8 compile caching via entrypoint shims#59720
Enable Node.js/v8 compile caching via entrypoint shims#59720jakebailey merged 8 commits intomicrosoft:mainfrom
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.
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.
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 hosts=node@20.17.0,node@22.8.0 |
|
@typescript-bot perf test startup-only hosts=node@20.17.0,node@22.8.0 |
|
@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.
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 hosts=node@20.17.0,node@22.8.0 |
|
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This makes use of nodejs/node#54501 by converting our larger entrypoints (
tsc,tsserver,typingsInstaller) into shims which callrequire("node:module").enableCompileCache(), thenrequirethe 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