Skip to content
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

Add new option "libReplacement", disable by default #60829

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jakebailey
Copy link
Member

Lib replacement (https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html#supporting-lib-from-node_modules) allows specially-named packages in node_modules to replace TypeScript's bundled lib.d.ts files. This feature is always on, so we always perform resolution to look for it in case it exists. This can have a negative perf impact; it's extra watchers, extra CPU time, extra IO, etc.

This PR adds a new compiler option libReplacement to control the feature; by default, it's disabled.

This is certainly a breaking change, but I'd like to run the extended tests / perf on this to see what happens.

The diff shows how much stuff we don't do when this option isn't enabled.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Dec 19, 2024
@jakebailey
Copy link
Member Author

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Dec 19, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started ✅ Results
run dt ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page.

Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up.

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user tests with tsc comparing main and refs/pull/60829/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

@jakebailey
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - node (v18.15.0, x64)
Errors 34 34 ~ ~ ~ p=1.000 n=6
Symbols 62,363 62,363 ~ ~ ~ p=1.000 n=6
Types 50,395 50,395 ~ ~ ~ p=1.000 n=6
Memory used 193,620k (± 0.76%) 193,000k (± 0.10%) ~ 192,861k 193,244k p=0.230 n=6
Parse Time 1.32s (± 0.42%) 1.30s (± 0.93%) ~ 1.29s 1.32s p=0.090 n=6
Bind Time 0.72s 0.71s -0.01s (- 1.39%) ~ ~ p=0.001 n=6
Check Time 9.76s (± 0.34%) 9.79s (± 0.20%) +0.04s (+ 0.36%) 9.76s 9.81s p=0.043 n=6
Emit Time 2.73s (± 0.73%) 2.73s (± 0.28%) ~ 2.72s 2.74s p=0.869 n=6
Total Time 14.52s (± 0.36%) 14.54s (± 0.17%) ~ 14.50s 14.56s p=0.628 n=6
angular-1 - node (v18.15.0, x64)
Errors 37 37 ~ ~ ~ p=1.000 n=6
Symbols 947,936 947,936 ~ ~ ~ p=1.000 n=6
Types 410,955 410,955 ~ ~ ~ p=1.000 n=6
Memory used 1,225,783k (± 0.00%) 1,224,782k (± 0.00%) -1,001k (- 0.08%) 1,224,709k 1,224,835k p=0.005 n=6
Parse Time 6.65s (± 0.62%) 6.55s (± 0.56%) -0.10s (- 1.48%) 6.51s 6.60s p=0.006 n=6
Bind Time 1.89s (± 0.29%) 1.88s (± 1.28%) ~ 1.86s 1.93s p=0.228 n=6
Check Time 31.99s (± 0.37%) 31.96s (± 0.41%) ~ 31.80s 32.13s p=0.810 n=6
Emit Time 15.19s (± 0.25%) 15.12s (± 0.65%) ~ 14.93s 15.21s p=0.126 n=6
Total Time 55.71s (± 0.17%) 55.52s (± 0.35%) -0.19s (- 0.34%) 55.21s 55.75s p=0.045 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,449,172 2,449,172 ~ ~ ~ p=1.000 n=6
Types 896,410 896,410 ~ ~ ~ p=1.000 n=6
Memory used 2,320,766k (± 0.00%) 2,319,699k (± 0.00%) -1,067k (- 0.05%) 2,319,654k 2,319,791k p=0.005 n=6
Parse Time 9.40s (± 0.20%) 9.39s (± 0.13%) ~ 9.37s 9.40s p=0.406 n=6
Bind Time 2.24s (± 0.18%) 2.24s (± 0.37%) ~ 2.23s 2.25s p=0.285 n=6
Check Time 73.51s (± 0.49%) 73.73s (± 0.64%) ~ 72.92s 74.18s p=0.298 n=6
Emit Time 0.27s (± 1.89%) 0.28s +0.01s (+ 2.44%) ~ ~ p=0.025 n=6
Total Time 85.42s (± 0.43%) 85.63s (± 0.54%) ~ 84.83s 86.08s p=0.298 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,226,880 1,226,965 +85 (+ 0.01%) ~ ~ p=0.001 n=6
Types 266,745 266,768 +23 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 2,357,644k (± 0.02%) 2,457,134k (± 7.64%) ~ 2,335,833k 2,699,767k p=0.378 n=6
Parse Time 5.22s (± 1.19%) 5.21s (± 1.33%) ~ 5.16s 5.34s p=0.689 n=6
Bind Time 1.75s (± 0.86%) 1.76s (± 1.04%) ~ 1.73s 1.78s p=0.510 n=6
Check Time 35.23s (± 0.15%) 35.03s (± 0.65%) ~ 34.76s 35.39s p=0.066 n=6
Emit Time 2.96s (± 1.03%) 3.01s (± 0.98%) +0.05s (+ 1.63%) 2.96s 3.04s p=0.043 n=6
Total Time 45.18s (± 0.25%) 45.01s (± 0.42%) ~ 44.81s 45.37s p=0.066 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,226,880 1,226,965 +85 (+ 0.01%) ~ ~ p=0.001 n=6
Types 266,745 266,768 +23 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 2,911,942k (±12.86%) 3,131,439k (± 0.02%) ~ 3,130,166k 3,132,105k p=0.378 n=6
Parse Time 6.96s (± 1.31%) 6.91s (± 0.77%) ~ 6.84s 6.99s p=0.336 n=6
Bind Time 2.17s (± 1.65%) 2.18s (± 0.69%) ~ 2.16s 2.19s p=0.747 n=6
Check Time 42.81s (± 0.71%) 42.86s (± 0.50%) ~ 42.54s 43.08s p=0.936 n=6
Emit Time 3.52s (± 2.51%) 3.53s (± 1.36%) ~ 3.46s 3.59s p=1.000 n=6
Total Time 55.46s (± 0.54%) 55.50s (± 0.43%) ~ 55.14s 55.84s p=1.000 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 262,439 262,468 +29 (+ 0.01%) ~ ~ p=0.001 n=6
Types 106,628 106,646 +18 (+ 0.02%) ~ ~ p=0.001 n=6
Memory used 440,204k (± 0.01%) 439,119k (± 0.01%) -1,085k (- 0.25%) 439,031k 439,167k p=0.005 n=6
Parse Time 3.53s (± 1.33%) 3.44s (± 0.65%) -0.09s (- 2.41%) 3.41s 3.48s p=0.005 n=6
Bind Time 1.31s (± 1.63%) 1.29s (± 1.30%) ~ 1.27s 1.32s p=0.106 n=6
Check Time 18.94s (± 0.25%) 18.94s (± 0.30%) ~ 18.87s 19.02s p=0.872 n=6
Emit Time 1.53s (± 0.76%) 1.54s (± 1.27%) ~ 1.51s 1.56s p=0.222 n=6
Total Time 25.31s (± 0.30%) 25.22s (± 0.14%) ~ 25.16s 25.26s p=0.065 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 70 70 ~ ~ ~ p=1.000 n=6
Symbols 226,062 226,062 ~ ~ ~ p=1.000 n=6
Types 94,488 94,488 ~ ~ ~ p=1.000 n=6
Memory used 371,627k (± 0.01%) 370,508k (± 0.03%) -1,119k (- 0.30%) 370,451k 370,717k p=0.005 n=6
Parse Time 2.90s (± 1.17%) 2.87s (± 1.64%) ~ 2.78s 2.92s p=0.227 n=6
Bind Time 1.59s (± 0.97%) 1.58s (± 1.35%) ~ 1.56s 1.61s p=0.465 n=6
Check Time 16.44s (± 0.20%) 16.48s (± 0.34%) ~ 16.40s 16.55s p=0.261 n=6
Emit Time 0.00s (±244.70%) 0.00s (±244.70%) ~ 0.00s 0.01s p=1.000 n=6
Total Time 20.93s (± 0.21%) 20.93s (± 0.41%) ~ 20.79s 21.00s p=0.687 n=6
vscode - node (v18.15.0, x64)
Errors 3 3 ~ ~ ~ p=1.000 n=6
Symbols 3,224,468 3,224,468 ~ ~ ~ p=1.000 n=6
Types 1,109,187 1,109,187 ~ ~ ~ p=1.000 n=6
Memory used 3,290,008k (± 0.01%) 3,288,983k (± 0.01%) -1,026k (- 0.03%) 3,288,586k 3,289,252k p=0.005 n=6
Parse Time 14.14s (± 0.38%) 14.19s (± 0.62%) ~ 14.09s 14.34s p=0.227 n=6
Bind Time 4.56s (± 0.42%) 4.52s (± 0.23%) -0.04s (- 0.80%) 4.51s 4.54s p=0.007 n=6
Check Time 88.49s (± 3.32%) 89.01s (± 1.88%) ~ 86.76s 90.41s p=0.748 n=6
Emit Time 27.80s (± 8.64%) 28.00s (± 2.67%) ~ 27.40s 29.00s p=0.298 n=6
Total Time 134.98s (± 0.73%) 135.73s (± 0.71%) ~ 134.37s 136.56s p=0.230 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 291,562 291,562 ~ ~ ~ p=1.000 n=6
Types 118,971 118,971 ~ ~ ~ p=1.000 n=6
Memory used 445,402k (± 0.01%) 444,426k (± 0.03%) -977k (- 0.22%) 444,239k 444,607k p=0.005 n=6
Parse Time 4.08s (± 0.65%) 4.04s (± 1.05%) ~ 3.99s 4.09s p=0.106 n=6
Bind Time 1.79s (± 0.55%) 1.78s (± 1.26%) ~ 1.76s 1.82s p=0.391 n=6
Check Time 18.81s (± 0.33%) 18.84s (± 0.63%) ~ 18.64s 18.96s p=0.225 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 24.70s (± 0.35%) 24.66s (± 0.64%) ~ 24.41s 24.84s p=1.000 n=6
xstate-main - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 552,233 552,233 ~ ~ ~ p=1.000 n=6
Types 184,971 184,971 ~ ~ ~ p=1.000 n=6
Memory used 492,410k (± 0.01%) 491,348k (± 0.03%) -1,062k (- 0.22%) 491,069k 491,470k p=0.005 n=6
Parse Time 4.25s (± 0.24%) 4.20s (± 0.28%) -0.05s (- 1.14%) 4.18s 4.21s p=0.005 n=6
Bind Time 1.46s (± 0.35%) 1.47s (± 1.43%) ~ 1.44s 1.49s p=0.459 n=6
Check Time 24.11s (± 0.40%) 24.16s (± 0.95%) ~ 24.00s 24.61s p=1.000 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 29.81s (± 0.35%) 29.83s (± 0.76%) ~ 29.67s 30.28s p=0.471 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top 400 repos with tsc comparing main and refs/pull/60829/merge:

Everything looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants