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

Cache discriminated contextual types #58372

Merged
merged 6 commits into from
Apr 30, 2024
Merged

Conversation

ahejlsberg
Copy link
Member

While researching another issue, @jakebailey noticed this statement takes an exceedingly long time to type check. With the caching added in this PR, the check time for the statement drops from 250ms to about zero on my machine.

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

@typescript-bot test it

@jakebailey
Copy link
Member

@typescript-bot test it

Sorry, the new function app we had to deploy has some scaling issues being worked out.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 30, 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

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 Here are the results of running the user tests comparing main and refs/pull/58372/merge:

Everything looks good!

@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 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,154 62,154 ~ ~ ~ p=1.000 n=6
Types 50,273 50,273 ~ ~ ~ p=1.000 n=6
Memory used 192,256k (± 0.07%) 193,409k (± 0.96%) ~ 192,208k 195,802k p=0.378 n=6
Parse Time 1.29s (± 1.82%) 1.29s (± 1.80%) ~ 1.25s 1.31s p=0.935 n=6
Bind Time 0.72s 0.72s ~ ~ ~ p=1.000 n=6
Check Time 9.57s (± 0.40%) 9.53s (± 0.32%) ~ 9.49s 9.58s p=0.126 n=6
Emit Time 2.62s (± 0.68%) 2.63s (± 0.31%) ~ 2.62s 2.64s p=0.677 n=6
Total Time 14.20s (± 0.28%) 14.16s (± 0.25%) ~ 14.13s 14.22s p=0.171 n=6
angular-1 - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 945,322 945,322 ~ ~ ~ p=1.000 n=6
Types 408,088 408,088 ~ ~ ~ p=1.000 n=6
Memory used 1,222,131k (± 0.00%) 1,222,776k (± 0.00%) +645k (+ 0.05%) 1,222,725k 1,222,846k p=0.005 n=6
Parse Time 6.78s (± 0.30%) 6.77s (± 0.22%) ~ 6.75s 6.79s p=0.289 n=6
Bind Time 1.88s (± 0.62%) 1.88s (± 0.29%) ~ 1.87s 1.88s p=0.498 n=6
Check Time 31.34s (± 0.47%) 31.34s (± 0.62%) ~ 31.11s 31.65s p=0.873 n=6
Emit Time 14.74s (± 0.34%) 14.73s (± 1.11%) ~ 14.56s 15.01s p=0.521 n=6
Total Time 54.75s (± 0.30%) 54.72s (± 0.39%) ~ 54.45s 54.96s p=0.936 n=6
mui-docs - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 1,955,956 1,955,956 ~ ~ ~ p=1.000 n=6
Types 676,324 676,324 ~ ~ ~ p=1.000 n=6
Memory used 1,754,529k (± 0.00%) 1,757,311k (± 0.00%) +2,782k (+ 0.16%) 1,757,287k 1,757,337k p=0.005 n=6
Parse Time 6.72s (± 0.33%) 6.73s (± 0.11%) ~ 6.72s 6.74s p=1.000 n=6
Bind Time 2.30s (± 0.51%) 2.29s (± 0.24%) ~ 2.29s 2.30s p=0.859 n=6
Check Time 56.80s (± 0.34%) 55.92s (± 0.21%) -0.87s (- 1.54%) 55.71s 56.02s p=0.005 n=6
Emit Time 0.14s (± 5.44%) 0.13s (± 3.87%) ~ 0.13s 0.14s p=0.247 n=6
Total Time 65.96s (± 0.32%) 65.08s (± 0.18%) -0.87s (- 1.32%) 64.87s 65.18s p=0.005 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,215,731 1,215,734 +3 (+ 0.00%) ~ ~ p=0.001 n=6
Types 257,647 257,647 ~ ~ ~ p=1.000 n=6
Memory used 2,324,027k (± 0.03%) 2,323,756k (± 0.02%) ~ 2,323,216k 2,324,229k p=0.298 n=6
Parse Time 4.96s (± 1.09%) 4.96s (± 1.00%) ~ 4.91s 5.05s p=0.936 n=6
Bind Time 1.88s (± 1.10%) 1.88s (± 0.22%) ~ 1.88s 1.89s p=0.246 n=6
Check Time 34.01s (± 0.36%) 33.33s (± 0.29%) -0.68s (- 2.00%) 33.19s 33.43s p=0.005 n=6
Emit Time 2.59s (± 0.63%) 2.61s (± 1.33%) ~ 2.58s 2.67s p=0.627 n=6
Total Time 43.44s (± 0.25%) 42.79s (± 0.26%) -0.64s (- 1.48%) 42.58s 42.87s p=0.005 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,215,731 1,215,734 +3 (+ 0.00%) ~ ~ p=0.001 n=6
Types 257,647 257,647 ~ ~ ~ p=1.000 n=6
Memory used 2,399,215k (± 0.03%) 2,398,341k (± 0.00%) -874k (- 0.04%) 2,398,239k 2,398,435k p=0.005 n=6
Parse Time 6.21s (± 0.57%) 6.17s (± 0.69%) ~ 6.11s 6.23s p=0.169 n=6
Bind Time 2.01s (± 0.91%) 2.01s (± 1.62%) ~ 1.97s 2.06s p=0.935 n=6
Check Time 40.51s (± 0.27%) 39.87s (± 0.26%) -0.64s (- 1.57%) 39.70s 39.99s p=0.005 n=6
Emit Time 3.12s (± 2.47%) 3.14s (± 1.65%) ~ 3.05s 3.19s p=0.689 n=6
Total Time 51.87s (± 0.26%) 51.23s (± 0.16%) -0.63s (- 1.22%) 51.11s 51.33s p=0.005 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 256,206 256,209 +3 (+ 0.00%) ~ ~ p=0.001 n=6
Types 103,653 103,653 ~ ~ ~ p=1.000 n=6
Memory used 424,265k (± 0.01%) 424,235k (± 0.01%) ~ 424,201k 424,297k p=0.230 n=6
Parse Time 3.34s (± 1.17%) 3.40s (± 3.34%) ~ 3.33s 3.63s p=0.418 n=6
Bind Time 1.31s (± 0.75%) 1.30s (± 0.90%) ~ 1.28s 1.31s p=0.177 n=6
Check Time 18.32s (± 0.44%) 17.74s (± 0.29%) 🟩-0.58s (- 3.18%) 17.68s 17.81s p=0.005 n=6
Emit Time 1.36s (± 1.77%) 1.36s (± 2.37%) ~ 1.33s 1.41s p=0.936 n=6
Total Time 24.34s (± 0.38%) 23.80s (± 0.64%) -0.54s (- 2.20%) 23.70s 24.11s p=0.005 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 224,824 224,824 ~ ~ ~ p=1.000 n=6
Types 93,390 93,390 ~ ~ ~ p=1.000 n=6
Memory used 369,318k (± 0.01%) 369,313k (± 0.02%) ~ 369,248k 369,422k p=0.521 n=6
Parse Time 2.83s (± 1.53%) 2.85s (± 0.69%) ~ 2.81s 2.86s p=0.195 n=6
Bind Time 1.59s (± 0.69%) 1.59s (± 1.17%) ~ 1.57s 1.62s p=0.510 n=6
Check Time 15.72s (± 0.40%) 15.61s (± 0.40%) -0.11s (- 0.71%) 15.51s 15.68s p=0.010 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 20.14s (± 0.41%) 20.04s (± 0.40%) -0.10s (- 0.51%) 19.92s 20.16s p=0.044 n=6
vscode - node (v18.15.0, x64)
Errors 4 4 ~ ~ ~ p=1.000 n=6
Symbols 2,799,544 2,799,544 ~ ~ ~ p=1.000 n=6
Types 950,964 950,964 ~ ~ ~ p=1.000 n=6
Memory used 2,927,257k (± 0.01%) 2,928,489k (± 0.00%) +1,232k (+ 0.04%) 2,928,315k 2,928,557k p=0.005 n=6
Parse Time 13.35s (± 0.42%) 13.30s (± 0.23%) ~ 13.27s 13.35s p=0.126 n=6
Bind Time 4.26s (± 1.92%) 4.13s (± 1.96%) ~ 4.08s 4.29s p=0.050 n=6
Check Time 73.00s (± 0.39%) 73.22s (± 0.64%) ~ 72.52s 73.75s p=0.298 n=6
Emit Time 20.08s (± 4.72%) 20.93s (± 9.49%) ~ 19.59s 23.58s p=0.810 n=6
Total Time 110.69s (± 1.03%) 111.58s (± 1.77%) ~ 110.01s 114.72s p=0.471 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 265,858 265,858 ~ ~ ~ p=1.000 n=6
Types 108,442 108,442 ~ ~ ~ p=1.000 n=6
Memory used 410,472k (± 0.01%) 410,410k (± 0.02%) ~ 410,323k 410,490k p=0.230 n=6
Parse Time 4.76s (± 0.25%) 4.76s (± 0.68%) ~ 4.72s 4.80s p=0.936 n=6
Bind Time 2.06s (± 1.24%) 2.06s (± 0.73%) ~ 2.05s 2.08s p=0.935 n=6
Check Time 21.10s (± 0.53%) 20.92s (± 0.26%) -0.17s (- 0.83%) 20.85s 21.01s p=0.013 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 27.92s (± 0.38%) 27.74s (± 0.27%) -0.18s (- 0.64%) 27.65s 27.87s p=0.016 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 524,146 524,146 ~ ~ ~ p=1.000 n=6
Types 178,732 178,732 ~ ~ ~ p=1.000 n=6
Memory used 461,405k (± 0.02%) 462,183k (± 0.01%) +779k (+ 0.17%) 462,144k 462,293k p=0.005 n=6
Parse Time 3.90s (± 0.75%) 3.90s (± 0.68%) ~ 3.86s 3.93s p=1.000 n=6
Bind Time 1.47s (± 0.55%) 1.47s (± 0.82%) ~ 1.45s 1.48s p=0.354 n=6
Check Time 22.55s (± 0.97%) 22.44s (± 0.65%) ~ 22.21s 22.59s p=0.229 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 27.92s (± 0.71%) 27.81s (± 0.45%) ~ 27.61s 27.91s p=0.199 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

@jakebailey
Copy link
Member

Wow, that's actually significant., 3% on our self test (expected), but also 1.5% in mui-docs.

Copy link
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly surprised we call this with the same arguments so many times - but I guess at least twice with the same args is basically guaranteed, since signature inference is 2-pass.

@ahejlsberg
Copy link
Member Author

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 30, 2024

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

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

@typescript-bot
Copy link
Collaborator

@ahejlsberg
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 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,154 62,154 ~ ~ ~ p=1.000 n=6
Types 50,273 50,273 ~ ~ ~ p=1.000 n=6
Memory used 193,518k (± 0.92%) 194,037k (± 1.02%) ~ 192,208k 196,008k p=1.000 n=6
Parse Time 1.31s (± 0.96%) 1.31s (± 0.64%) ~ 1.29s 1.31s p=0.735 n=6
Bind Time 0.72s 0.72s ~ ~ ~ p=1.000 n=6
Check Time 9.55s (± 0.39%) 9.55s (± 0.28%) ~ 9.51s 9.59s p=1.000 n=6
Emit Time 2.62s (± 0.62%) 2.63s (± 0.54%) ~ 2.61s 2.65s p=0.194 n=6
Total Time 14.19s (± 0.39%) 14.20s (± 0.18%) ~ 14.16s 14.23s p=1.000 n=6
angular-1 - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 945,322 945,923 +601 (+ 0.06%) ~ ~ p=0.001 n=6
Types 408,088 408,398 +310 (+ 0.08%) ~ ~ p=0.001 n=6
Memory used 1,222,099k (± 0.00%) 1,222,740k (± 0.00%) +641k (+ 0.05%) 1,222,660k 1,222,828k p=0.005 n=6
Parse Time 6.77s (± 0.76%) 6.77s (± 0.46%) ~ 6.75s 6.83s p=0.807 n=6
Bind Time 1.87s (± 0.44%) 1.87s (± 0.52%) ~ 1.86s 1.88s p=0.862 n=6
Check Time 31.45s (± 0.56%) 31.26s (± 0.30%) ~ 31.13s 31.38s p=0.109 n=6
Emit Time 14.63s (± 1.19%) 14.74s (± 0.52%) ~ 14.64s 14.82s p=0.199 n=6
Total Time 54.72s (± 0.49%) 54.65s (± 0.30%) ~ 54.46s 54.86s p=0.809 n=6
mui-docs - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 1,955,956 1,999,695 +43,739 (+ 2.24%) ~ ~ p=0.001 n=6
Types 676,324 681,527 +5,203 (+ 0.77%) ~ ~ p=0.001 n=6
Memory used 1,754,535k (± 0.00%) 1,781,555k (± 0.00%) +27,020k (+ 1.54%) 1,781,507k 1,781,587k p=0.005 n=6
Parse Time 6.71s (± 0.36%) 6.71s (± 0.37%) ~ 6.68s 6.74s p=0.936 n=6
Bind Time 2.31s (± 0.52%) 2.30s (± 0.27%) ~ 2.29s 2.31s p=0.340 n=6
Check Time 56.86s (± 0.38%) 56.58s (± 0.31%) -0.28s (- 0.50%) 56.27s 56.77s p=0.037 n=6
Emit Time 0.14s (± 2.95%) 0.14s (± 2.88%) ~ 0.14s 0.15s p=0.218 n=6
Total Time 66.01s (± 0.34%) 65.72s (± 0.27%) ~ 65.44s 65.92s p=0.054 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,215,731 1,216,274 +543 (+ 0.04%) ~ ~ p=0.001 n=6
Types 257,647 257,948 +301 (+ 0.12%) ~ ~ p=0.001 n=6
Memory used 2,324,685k (± 0.03%) 2,322,980k (± 0.02%) -1,705k (- 0.07%) 2,322,555k 2,323,639k p=0.005 n=6
Parse Time 4.96s (± 0.16%) 4.97s (± 0.77%) ~ 4.92s 5.03s p=0.258 n=6
Bind Time 1.88s (± 0.62%) 1.87s (± 1.37%) ~ 1.85s 1.91s p=0.328 n=6
Check Time 34.04s (± 0.35%) 33.49s (± 0.46%) -0.54s (- 1.59%) 33.24s 33.64s p=0.005 n=6
Emit Time 2.59s (± 2.50%) 2.62s (± 2.53%) ~ 2.51s 2.69s p=0.378 n=6
Total Time 43.47s (± 0.39%) 42.97s (± 0.42%) -0.50s (- 1.15%) 42.71s 43.18s p=0.005 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,215,731 1,216,274 +543 (+ 0.04%) ~ ~ p=0.001 n=6
Types 257,647 257,948 +301 (+ 0.12%) ~ ~ p=0.001 n=6
Memory used 2,398,813k (± 0.02%) 2,398,153k (± 0.02%) ~ 2,397,364k 2,398,623k p=0.066 n=6
Parse Time 6.21s (± 1.04%) 6.24s (± 1.17%) ~ 6.14s 6.33s p=0.688 n=6
Bind Time 2.03s (± 1.60%) 2.02s (± 0.68%) ~ 2.01s 2.05s p=0.332 n=6
Check Time 40.63s (± 0.32%) 39.85s (± 0.28%) -0.78s (- 1.93%) 39.75s 40.05s p=0.005 n=6
Emit Time 3.13s (± 2.12%) 3.11s (± 1.68%) ~ 3.02s 3.17s p=0.575 n=6
Total Time 52.02s (± 0.14%) 51.24s (± 0.24%) -0.78s (- 1.51%) 51.08s 51.43s p=0.005 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 256,206 256,432 +226 (+ 0.09%) ~ ~ p=0.001 n=6
Types 103,653 103,607 -46 (- 0.04%) ~ ~ p=0.001 n=6
Memory used 424,264k (± 0.00%) 424,324k (± 0.01%) +61k (+ 0.01%) 424,278k 424,372k p=0.008 n=6
Parse Time 3.32s (± 1.62%) 3.34s (± 0.99%) ~ 3.29s 3.38s p=0.629 n=6
Bind Time 1.30s (± 0.58%) 1.30s (± 0.80%) ~ 1.28s 1.31s p=0.437 n=6
Check Time 18.27s (± 0.35%) 17.73s (± 0.20%) -0.53s (- 2.92%) 17.70s 17.80s p=0.005 n=6
Emit Time 1.35s (± 1.09%) 1.37s (± 1.22%) ~ 1.35s 1.39s p=0.087 n=6
Total Time 24.24s (± 0.38%) 23.74s (± 0.26%) -0.50s (- 2.06%) 23.67s 23.84s p=0.005 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 224,824 225,034 +210 (+ 0.09%) ~ ~ p=0.001 n=6
Types 93,390 93,347 -43 (- 0.05%) ~ ~ p=0.001 n=6
Memory used 369,288k (± 0.01%) 369,416k (± 0.02%) +128k (+ 0.03%) 369,344k 369,598k p=0.005 n=6
Parse Time 3.49s (± 0.97%) 3.51s (± 0.42%) ~ 3.49s 3.53s p=0.167 n=6
Bind Time 1.92s (± 0.64%) 1.94s (± 1.64%) ~ 1.91s 1.98s p=0.675 n=6
Check Time 19.43s (± 0.33%) 19.33s (± 0.29%) -0.10s (- 0.51%) 19.23s 19.38s p=0.013 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 24.84s (± 0.27%) 24.78s (± 0.33%) ~ 24.64s 24.85s p=0.230 n=6
vscode - node (v18.15.0, x64)
Errors 4 4 ~ ~ ~ p=1.000 n=6
Symbols 2,799,544 2,801,275 +1,731 (+ 0.06%) ~ ~ p=0.001 n=6
Types 950,964 950,758 -206 (- 0.02%) ~ ~ p=0.001 n=6
Memory used 2,927,051k (± 0.01%) 2,927,911k (± 0.01%) +860k (+ 0.03%) 2,927,421k 2,928,160k p=0.005 n=6
Parse Time 13.38s (± 0.53%) 13.31s (± 0.26%) ~ 13.28s 13.37s p=0.076 n=6
Bind Time 4.29s (± 0.27%) 4.16s (± 2.77%) ~ 4.08s 4.32s p=0.167 n=6
Check Time 73.00s (± 0.31%) 72.58s (± 0.37%) -0.42s (- 0.57%) 72.30s 73.03s p=0.031 n=6
Emit Time 21.05s (± 7.68%) 21.11s (± 8.23%) ~ 19.55s 23.35s p=0.575 n=6
Total Time 111.72s (± 1.46%) 111.16s (± 1.40%) ~ 109.47s 113.18s p=0.471 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 265,858 265,858 ~ ~ ~ p=1.000 n=6
Types 108,442 108,442 ~ ~ ~ p=1.000 n=6
Memory used 410,483k (± 0.02%) 410,427k (± 0.01%) ~ 410,349k 410,496k p=0.128 n=6
Parse Time 4.77s (± 1.18%) 4.74s (± 0.71%) ~ 4.71s 4.80s p=0.333 n=6
Bind Time 2.08s (± 0.95%) 2.06s (± 0.90%) ~ 2.04s 2.09s p=0.280 n=6
Check Time 21.18s (± 0.22%) 20.98s (± 0.17%) -0.20s (- 0.95%) 20.92s 21.02s p=0.005 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 28.03s (± 0.32%) 27.79s (± 0.24%) -0.24s (- 0.87%) 27.69s 27.89s p=0.005 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 524,146 553,173 🔻+29,027 (+ 5.54%) ~ ~ p=0.001 n=6
Types 178,732 188,311 🔻+9,579 (+ 5.36%) ~ ~ p=0.001 n=6
Memory used 461,380k (± 0.02%) 476,795k (± 0.03%) +15,416k (+ 3.34%) 476,628k 476,998k p=0.005 n=6
Parse Time 3.89s (± 0.32%) 3.89s (± 0.70%) ~ 3.85s 3.93s p=1.000 n=6
Bind Time 1.46s (± 1.28%) 1.47s (± 1.34%) ~ 1.43s 1.48s p=0.870 n=6
Check Time 22.56s (± 0.79%) 22.78s (± 0.40%) +0.23s (+ 1.00%) 22.68s 22.92s p=0.031 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 27.91s (± 0.62%) 28.14s (± 0.42%) +0.23s (+ 0.82%) 27.99s 28.28s p=0.045 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

@ahejlsberg
Copy link
Member Author

Hmm, removing null and undefined from apparent contextual types seems to be a net negative. I'll get rid of that again.

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@ahejlsberg ahejlsberg merged commit 749bd83 into main Apr 30, 2024
28 checks passed
@ahejlsberg ahejlsberg deleted the cacheDiscriminatedContextualTypes branch April 30, 2024 19:40
@ssalbdivad
Copy link

I bisected a perf regression typechecking https://github.com/arktypeio/arktype and found the following:

{
    "checkTime": 9.68,
    "types": 483415,
    "instantiations": 2629152
}

devDependencies:
- typescript 5.5.0-dev.20240429
+ typescript 5.5.0-dev.20240430

{
    "checkTime": 12.2,
    "types": 514846,
    "instantiations": 2819487
}

It seems likely this change was somehow involved?

@Andarist
Copy link
Contributor

Andarist commented Jun 7, 2024

Guided by package.json#gitHead in both of those we can see the diff between those versions here:
3358157...dc316af

This PR isn't part of that.

@ssalbdivad
Copy link

My mistake, I likely jumped to conclusions when I saw this in the release notes as a likely candidate since I use quite a lot of unions internally.

@Andarist and I have been looking at which of the changes from that day could have caused such a large increase in type instantiations and check time and haven't been able to identify it yet.

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.

6 participants