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

Derive tuple labels for rest elements from array binding patterns #59045

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rbuckton
Copy link
Member

@rbuckton rbuckton commented Jun 26, 2024

While working on #58243, a community member asked if we could label the tuple we use to properly type arguments to the next() methods of iterators and generators. A brief experiment showed that directly labeling the tuple element resulted in the creation of thousands of new types in some tests since iterator/generator instantiations would produce new named tuple elements since named tuple elements are cached far less frequently.

An alternative to that approach would be to use an additional source for the label when the label comes from a rest parameter whose name is actually an ArrayBindingPattern:

declare function a(...args: [] | [number]): void;
a(1); // quickinfo shows `(args_0: number)`

declare function b(...[value] : [] | [number]): void;
b(1); // quickinfo now shows `(value: number)`
      // quickinfo previously showed `(__0_0: number)`

Since this is merely treated as an additional labeling source, there is no need to synthesize additional types for named tuple elements.

Related #58243 (comment)

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

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 27, 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 @DanielRosenwasser, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@typescript-bot
Copy link
Collaborator

@DanielRosenwasser
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,153 62,153 ~ ~ ~ p=1.000 n=6
Types 50,242 50,242 ~ ~ ~ p=1.000 n=6
Memory used 192,789k (± 0.75%) 192,789k (± 0.73%) ~ 192,133k 195,637k p=0.575 n=6
Parse Time 1.31s (± 0.57%) 1.30s (± 1.05%) ~ 1.28s 1.32s p=0.273 n=6
Bind Time 0.71s 0.71s ~ ~ ~ p=1.000 n=6
Check Time 9.44s (± 0.38%) 9.44s (± 0.69%) ~ 9.38s 9.55s p=0.936 n=6
Emit Time 2.75s (± 0.83%) 2.74s (± 1.37%) ~ 2.67s 2.78s p=1.000 n=6
Total Time 14.21s (± 0.30%) 14.20s (± 0.24%) ~ 14.17s 14.25s p=0.744 n=6
angular-1 - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 944,114 944,114 ~ ~ ~ p=1.000 n=6
Types 407,050 407,050 ~ ~ ~ p=1.000 n=6
Memory used 1,218,382k (± 0.00%) 1,218,347k (± 0.00%) ~ 1,218,275k 1,218,373k p=0.335 n=6
Parse Time 6.67s (± 0.74%) 6.66s (± 0.92%) ~ 6.59s 6.76s p=0.809 n=6
Bind Time 1.87s (± 0.55%) 1.87s (± 0.56%) ~ 1.85s 1.88s p=0.801 n=6
Check Time 30.64s (± 0.19%) 30.72s (± 0.29%) ~ 30.59s 30.81s p=0.148 n=6
Emit Time 13.54s (± 0.68%) 13.57s (± 0.31%) ~ 13.52s 13.62s p=1.000 n=6
Total Time 52.72s (± 0.16%) 52.81s (± 0.23%) ~ 52.65s 52.97s p=0.229 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,132,386 2,132,386 ~ ~ ~ p=1.000 n=6
Types 926,170 926,170 ~ ~ ~ p=1.000 n=6
Memory used 2,114,738k (± 0.01%) 2,114,843k (± 0.01%) ~ 2,114,648k 2,115,034k p=0.173 n=6
Parse Time 9.72s (± 0.25%) 9.73s (± 0.31%) ~ 9.70s 9.78s p=0.685 n=6
Bind Time 3.40s (± 0.69%) 3.39s (± 0.94%) ~ 3.34s 3.43s p=0.683 n=6
Check Time 103.00s (± 0.57%) 102.02s (± 1.35%) ~ 99.52s 103.17s p=0.173 n=6
Emit Time 0.19s (± 2.13%) 0.19s (± 2.67%) ~ 0.19s 0.20s p=0.595 n=6
Total Time 116.31s (± 0.50%) 115.33s (± 1.18%) ~ 112.87s 116.46s p=0.173 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,231,640 1,231,657 +17 (+ 0.00%) ~ ~ p=0.001 n=6
Types 261,187 261,211 +24 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 2,347,576k (± 0.04%) 2,347,596k (± 0.03%) ~ 2,346,508k 2,348,766k p=1.000 n=6
Parse Time 5.06s (± 0.44%) 5.05s (± 0.45%) ~ 5.03s 5.09s p=0.810 n=6
Bind Time 1.93s (± 0.79%) 1.93s (± 0.42%) ~ 1.93s 1.95s p=0.209 n=6
Check Time 34.05s (± 0.22%) 34.16s (± 0.49%) ~ 33.94s 34.38s p=0.230 n=6
Emit Time 2.76s (± 2.56%) 2.73s (± 1.95%) ~ 2.67s 2.81s p=0.471 n=6
Total Time 43.82s (± 0.30%) 43.90s (± 0.41%) ~ 43.72s 44.16s p=0.689 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,231,640 1,231,657 +17 (+ 0.00%) ~ ~ p=0.001 n=6
Types 261,187 261,211 +24 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 2,424,424k (± 0.06%) 2,423,830k (± 0.02%) ~ 2,423,060k 2,424,766k p=0.936 n=6
Parse Time 6.25s (± 0.61%) 6.24s (± 1.16%) ~ 6.15s 6.36s p=0.630 n=6
Bind Time 2.05s (± 0.67%) 2.04s (± 0.74%) ~ 2.01s 2.05s p=0.324 n=6
Check Time 40.40s (± 0.26%) 40.51s (± 0.19%) ~ 40.40s 40.61s p=0.128 n=6
Emit Time 3.24s (± 2.66%) 3.25s (± 2.35%) ~ 3.17s 3.36s p=0.873 n=6
Total Time 51.95s (± 0.34%) 52.04s (± 0.31%) ~ 51.87s 52.29s p=0.422 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 258,818 258,835 +17 (+ 0.01%) ~ ~ p=0.001 n=6
Types 104,842 104,866 +24 (+ 0.02%) ~ ~ p=0.001 n=6
Memory used 428,204k (± 0.01%) 428,303k (± 0.01%) +100k (+ 0.02%) 428,252k 428,362k p=0.008 n=6
Parse Time 3.31s (± 1.17%) 3.33s (± 1.18%) ~ 3.30s 3.41s p=0.455 n=6
Bind Time 1.31s (± 1.64%) 1.31s (± 1.31%) ~ 1.29s 1.34s p=1.000 n=6
Check Time 17.80s (± 0.26%) 17.80s (± 0.37%) ~ 17.70s 17.86s p=0.872 n=6
Emit Time 1.36s (± 1.59%) 1.38s (± 0.92%) ~ 1.36s 1.39s p=0.217 n=6
Total Time 23.79s (± 0.34%) 23.82s (± 0.41%) ~ 23.68s 23.95s p=0.574 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 224,565 224,565 ~ ~ ~ p=1.000 n=6
Types 93,734 93,734 ~ ~ ~ p=1.000 n=6
Memory used 369,518k (± 0.03%) 369,412k (± 0.02%) ~ 369,312k 369,477k p=0.093 n=6
Parse Time 2.78s (± 1.87%) 2.77s (± 0.96%) ~ 2.72s 2.80s p=0.126 n=6
Bind Time 1.58s (± 1.03%) 1.58s (± 0.67%) ~ 1.56s 1.59s p=0.451 n=6
Check Time 15.47s (± 0.32%) 15.45s (± 0.39%) ~ 15.36s 15.51s p=0.688 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 19.84s (± 0.27%) 19.79s (± 0.42%) ~ 19.65s 19.87s p=0.261 n=6
vscode - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,878,579 2,878,579 ~ ~ ~ p=1.000 n=6
Types 975,166 975,166 ~ ~ ~ p=1.000 n=6
Memory used 3,042,078k (± 0.00%) 3,042,073k (± 0.00%) ~ 3,042,019k 3,042,125k p=0.936 n=6
Parse Time 13.54s (± 0.32%) 13.59s (± 0.23%) ~ 13.54s 13.63s p=0.056 n=6
Bind Time 4.22s (± 2.03%) 4.18s (± 0.21%) ~ 4.17s 4.19s p=0.459 n=6
Check Time 73.36s (± 0.39%) 73.21s (± 0.27%) ~ 73.00s 73.48s p=0.230 n=6
Emit Time 23.98s (± 0.38%) 23.98s (± 0.24%) ~ 23.91s 24.05s p=0.936 n=6
Total Time 115.09s (± 0.30%) 114.96s (± 0.17%) ~ 114.79s 115.31s p=0.378 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 267,117 267,117 ~ ~ ~ p=1.000 n=6
Types 108,775 108,775 ~ ~ ~ p=1.000 n=6
Memory used 411,543k (± 0.01%) 411,524k (± 0.02%) ~ 411,431k 411,593k p=0.810 n=6
Parse Time 3.19s (± 0.54%) 3.19s (± 0.55%) ~ 3.17s 3.22s p=0.870 n=6
Bind Time 1.42s (± 0.59%) 1.41s (± 0.37%) ~ 1.41s 1.42s p=0.533 n=6
Check Time 14.20s (± 0.37%) 14.22s (± 0.51%) ~ 14.13s 14.30s p=0.520 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 18.80s (± 0.21%) 18.83s (± 0.36%) ~ 18.76s 18.91s p=0.521 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 525,251 525,251 ~ ~ ~ p=1.000 n=6
Types 178,574 178,574 ~ ~ ~ p=1.000 n=6
Memory used 462,859k (± 0.09%) 462,680k (± 0.08%) ~ 462,336k 463,129k p=0.471 n=6
Parse Time 3.17s (± 0.68%) 3.16s (± 0.99%) ~ 3.13s 3.21s p=0.418 n=6
Bind Time 1.17s (± 1.14%) 1.17s ~ ~ ~ p=0.599 n=6
Check Time 17.99s (± 0.24%) 17.95s (± 0.33%) ~ 17.89s 18.03s p=0.296 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 22.34s (± 0.16%) 22.28s (± 0.33%) ~ 22.20s 22.38s p=0.228 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

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

Everything looks good!

@Andarist
Copy link
Contributor

I already have a very related change to this open here. Both PRs touch the same area of the code and solve very overlapping problems, I think it would make sense to merge both

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
Status: Waiting on reviewers
Development

Successfully merging this pull request may close these issues.

None yet

4 participants