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

Eliminate redundant or meaningless elaborations in type relations #47738

Merged
merged 19 commits into from
Feb 15, 2022

Conversation

ahejlsberg
Copy link
Member

@ahejlsberg ahejlsberg commented Feb 4, 2022

This PR removes a several pointless error elaborations, making diagnostics more concise. For example, when there is no relation between some source type and a target union type, we now only elaborate when we can identify a best match on the target side. Previously we'd default to elaborating on the last target constituent, which generally just adds noise and depends on a unstable sort order.

The PR also optimizies the isRelatedTo function by moving more work to the cached side on relationship checking. This improves checker performance by up to 3% and fixes an issue related to infinite constraints involving intersections.

Fixes #46900.
Fixes #47668.

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Feb 4, 2022
@ahejlsberg
Copy link
Member Author

@typescript-bot test this
@typescript-bot user test this inline
@typescript-bot run dt
@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 4, 2022

Heya @ahejlsberg, I've started to run the extended test suite on this PR at a009ee1. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 4, 2022

Heya @ahejlsberg, I've started to run the perf test suite on this PR at a009ee1. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 4, 2022

Heya @ahejlsberg, I've started to run the diff-based community code test suite on this PR at a009ee1. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 4, 2022

Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at a009ee1. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

@ahejlsberg
Great news! no new errors were found between main..refs/pull/47738/merge

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..47738

Metric main 47738 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 356,379k (± 0.01%) 356,374k (± 0.02%) -5k (- 0.00%) 356,222k 356,487k
Parse Time 1.96s (± 0.58%) 1.95s (± 0.57%) -0.00s (- 0.15%) 1.93s 1.98s
Bind Time 0.86s (± 0.69%) 0.86s (± 0.95%) +0.00s (+ 0.47%) 0.84s 0.88s
Check Time 5.60s (± 0.58%) 5.61s (± 0.52%) +0.01s (+ 0.18%) 5.52s 5.66s
Emit Time 5.93s (± 0.59%) 5.94s (± 0.63%) +0.00s (+ 0.07%) 5.86s 6.02s
Total Time 14.35s (± 0.43%) 14.36s (± 0.44%) +0.01s (+ 0.09%) 14.18s 14.46s
Compiler-Unions - node (v10.16.3, x64)
Memory used 204,276k (± 0.03%) 204,078k (± 0.04%) -198k (- 0.10%) 203,833k 204,230k
Parse Time 0.79s (± 0.87%) 0.79s (± 0.74%) +0.00s (+ 0.13%) 0.77s 0.80s
Bind Time 0.53s (± 1.45%) 0.53s (± 1.45%) 0.00s ( 0.00%) 0.51s 0.54s
Check Time 7.87s (± 0.37%) 7.91s (± 0.71%) +0.04s (+ 0.51%) 7.81s 8.04s
Emit Time 2.48s (± 1.05%) 2.47s (± 0.77%) -0.01s (- 0.28%) 2.43s 2.52s
Total Time 11.65s (± 0.23%) 11.69s (± 0.62%) +0.04s (+ 0.30%) 11.57s 11.87s
Monaco - node (v10.16.3, x64)
Memory used 342,676k (± 0.02%) 342,707k (± 0.02%) +31k (+ 0.01%) 342,602k 342,850k
Parse Time 1.48s (± 0.55%) 1.49s (± 0.54%) +0.01s (+ 0.61%) 1.47s 1.51s
Bind Time 0.76s (± 0.65%) 0.76s (± 0.65%) +0.00s (+ 0.00%) 0.75s 0.77s
Check Time 5.55s (± 0.57%) 5.54s (± 0.40%) -0.01s (- 0.25%) 5.49s 5.58s
Emit Time 3.23s (± 1.35%) 3.24s (± 0.93%) +0.01s (+ 0.40%) 3.17s 3.30s
Total Time 11.01s (± 0.35%) 11.02s (± 0.20%) +0.01s (+ 0.06%) 10.96s 11.06s
TFS - node (v10.16.3, x64)
Memory used 305,786k (± 0.02%) 305,772k (± 0.02%) -14k (- 0.00%) 305,695k 305,893k
Parse Time 1.20s (± 0.43%) 1.20s (± 0.43%) -0.00s (- 0.17%) 1.19s 1.21s
Bind Time 0.71s (± 0.81%) 0.71s (± 0.96%) +0.00s (+ 0.28%) 0.70s 0.73s
Check Time 5.05s (± 0.45%) 5.06s (± 0.52%) +0.01s (+ 0.16%) 4.98s 5.10s
Emit Time 3.40s (± 0.93%) 3.37s (± 1.66%) -0.03s (- 0.94%) 3.27s 3.54s
Total Time 10.37s (± 0.28%) 10.35s (± 0.47%) -0.02s (- 0.19%) 10.22s 10.42s
material-ui - node (v10.16.3, x64)
Memory used 471,897k (± 0.01%) 469,870k (± 0.01%) -2,028k (- 0.43%) 469,755k 470,025k
Parse Time 1.77s (± 0.40%) 1.77s (± 0.34%) +0.00s (+ 0.23%) 1.76s 1.79s
Bind Time 0.66s (± 0.68%) 0.66s (± 0.61%) +0.00s (+ 0.46%) 0.65s 0.67s
Check Time 14.28s (± 0.27%) 14.19s (± 0.34%) -0.09s (- 0.64%) 14.10s 14.30s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.71s (± 0.23%) 16.63s (± 0.33%) -0.08s (- 0.48%) 16.53s 16.75s
xstate - node (v10.16.3, x64)
Memory used 570,518k (± 0.02%) 570,263k (± 0.01%) -255k (- 0.04%) 570,142k 570,447k
Parse Time 2.55s (± 0.29%) 2.56s (± 0.24%) +0.01s (+ 0.51%) 2.55s 2.57s
Bind Time 1.01s (± 0.59%) 1.01s (± 0.34%) -0.00s (- 0.20%) 1.01s 1.02s
Check Time 1.50s (± 0.72%) 1.49s (± 0.33%) -0.01s (- 0.87%) 1.48s 1.50s
Emit Time 0.07s (± 3.14%) 0.07s (± 3.14%) 0.00s ( 0.00%) 0.07s 0.08s
Total Time 5.13s (± 0.25%) 5.13s (± 0.15%) -0.00s (- 0.08%) 5.11s 5.14s
Angular - node (v12.1.0, x64)
Memory used 333,700k (± 0.13%) 334,153k (± 0.02%) +452k (+ 0.14%) 333,989k 334,349k
Parse Time 1.94s (± 0.48%) 1.94s (± 0.52%) +0.00s (+ 0.10%) 1.92s 1.96s
Bind Time 0.84s (± 0.59%) 0.84s (± 0.70%) -0.00s (- 0.12%) 0.83s 0.86s
Check Time 5.43s (± 0.67%) 5.44s (± 0.32%) +0.00s (+ 0.07%) 5.41s 5.49s
Emit Time 6.19s (± 0.67%) 6.17s (± 0.67%) -0.02s (- 0.29%) 6.10s 6.29s
Total Time 14.41s (± 0.47%) 14.40s (± 0.38%) -0.01s (- 0.09%) 14.30s 14.58s
Compiler-Unions - node (v12.1.0, x64)
Memory used 191,756k (± 0.03%) 191,681k (± 0.04%) -75k (- 0.04%) 191,502k 191,931k
Parse Time 0.78s (± 1.08%) 0.78s (± 0.71%) +0.00s (+ 0.13%) 0.77s 0.80s
Bind Time 0.53s (± 0.56%) 0.54s (± 1.14%) +0.01s (+ 1.32%) 0.53s 0.55s
Check Time 7.32s (± 0.34%) 7.40s (± 0.52%) +0.07s (+ 1.01%) 7.34s 7.49s
Emit Time 2.49s (± 0.97%) 2.48s (± 0.59%) -0.01s (- 0.36%) 2.46s 2.52s
Total Time 11.13s (± 0.39%) 11.20s (± 0.31%) +0.07s (+ 0.67%) 11.12s 11.30s
Monaco - node (v12.1.0, x64)
Memory used 325,550k (± 0.05%) 325,729k (± 0.01%) +179k (+ 0.05%) 325,614k 325,807k
Parse Time 1.47s (± 1.01%) 1.46s (± 0.83%) -0.01s (- 0.61%) 1.43s 1.49s
Bind Time 0.74s (± 0.91%) 0.75s (± 1.42%) +0.01s (+ 1.22%) 0.73s 0.78s
Check Time 5.42s (± 0.36%) 5.44s (± 0.65%) +0.03s (+ 0.50%) 5.38s 5.54s
Emit Time 3.22s (± 0.79%) 3.24s (± 0.65%) +0.02s (+ 0.53%) 3.20s 3.29s
Total Time 10.85s (± 0.35%) 10.89s (± 0.47%) +0.04s (+ 0.39%) 10.81s 11.06s
TFS - node (v12.1.0, x64)
Memory used 290,444k (± 0.02%) 290,399k (± 0.03%) -45k (- 0.02%) 290,211k 290,599k
Parse Time 1.21s (± 0.67%) 1.21s (± 0.28%) -0.01s (- 0.49%) 1.20s 1.21s
Bind Time 0.70s (± 0.49%) 0.70s (± 0.64%) +0.00s (+ 0.14%) 0.69s 0.71s
Check Time 4.99s (± 0.41%) 4.99s (± 0.50%) +0.00s (+ 0.08%) 4.95s 5.05s
Emit Time 3.42s (± 1.07%) 3.44s (± 0.75%) +0.02s (+ 0.61%) 3.39s 3.50s
Total Time 10.32s (± 0.39%) 10.34s (± 0.29%) +0.02s (+ 0.18%) 10.27s 10.39s
material-ui - node (v12.1.0, x64)
Memory used 450,607k (± 0.05%) 448,725k (± 0.06%) -1,882k (- 0.42%) 447,734k 448,936k
Parse Time 1.78s (± 0.52%) 1.78s (± 0.41%) -0.00s (- 0.22%) 1.77s 1.80s
Bind Time 0.64s (± 0.81%) 0.64s (± 0.56%) +0.00s (+ 0.47%) 0.64s 0.65s
Check Time 12.78s (± 0.38%) 12.78s (± 0.52%) -0.01s (- 0.05%) 12.67s 12.94s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.20s (± 0.39%) 15.20s (± 0.45%) -0.01s (- 0.04%) 15.08s 15.37s
xstate - node (v12.1.0, x64)
Memory used 536,428k (± 0.01%) 536,212k (± 0.02%) -216k (- 0.04%) 535,961k 536,400k
Parse Time 2.49s (± 0.54%) 2.49s (± 0.64%) +0.01s (+ 0.20%) 2.47s 2.53s
Bind Time 1.05s (± 0.57%) 1.05s (± 0.45%) +0.01s (+ 0.77%) 1.04s 1.06s
Check Time 1.44s (± 0.71%) 1.43s (± 0.57%) -0.01s (- 0.76%) 1.41s 1.44s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.05s (± 0.31%) 5.04s (± 0.33%) -0.01s (- 0.16%) 5.01s 5.09s
Angular - node (v14.15.1, x64)
Memory used 332,345k (± 0.01%) 332,359k (± 0.01%) +14k (+ 0.00%) 332,306k 332,402k
Parse Time 1.94s (± 0.43%) 1.94s (± 0.32%) -0.00s (- 0.21%) 1.93s 1.95s
Bind Time 0.88s (± 0.77%) 0.89s (± 0.79%) +0.00s (+ 0.57%) 0.87s 0.90s
Check Time 5.45s (± 0.46%) 5.46s (± 0.40%) +0.00s (+ 0.07%) 5.42s 5.52s
Emit Time 6.16s (± 0.48%) 6.17s (± 0.39%) +0.00s (+ 0.05%) 6.11s 6.21s
Total Time 14.44s (± 0.30%) 14.45s (± 0.27%) +0.01s (+ 0.06%) 14.36s 14.52s
Compiler-Unions - node (v14.15.1, x64)
Memory used 191,582k (± 0.66%) 193,470k (± 0.02%) +1,888k (+ 0.99%) 193,363k 193,564k
Parse Time 0.80s (± 0.59%) 0.81s (± 0.99%) +0.01s (+ 0.62%) 0.80s 0.83s
Bind Time 0.56s (± 0.80%) 0.56s (± 0.84%) +0.00s (+ 0.36%) 0.55s 0.57s
Check Time 7.41s (± 0.60%) 7.43s (± 0.63%) +0.02s (+ 0.22%) 7.33s 7.57s
Emit Time 2.49s (± 0.89%) 2.47s (± 0.92%) -0.03s (- 1.08%) 2.41s 2.52s
Total Time 11.26s (± 0.35%) 11.26s (± 0.39%) -0.00s (- 0.03%) 11.16s 11.39s
Monaco - node (v14.15.1, x64)
Memory used 324,502k (± 0.00%) 324,519k (± 0.00%) +18k (+ 0.01%) 324,486k 324,553k
Parse Time 1.50s (± 0.47%) 1.50s (± 0.71%) +0.00s (+ 0.33%) 1.49s 1.53s
Bind Time 0.77s (± 0.52%) 0.77s (± 0.94%) +0.00s (+ 0.13%) 0.76s 0.79s
Check Time 5.33s (± 0.41%) 5.34s (± 0.44%) +0.01s (+ 0.24%) 5.28s 5.38s
Emit Time 3.26s (± 0.42%) 3.26s (± 0.66%) +0.00s (+ 0.12%) 3.23s 3.32s
Total Time 10.86s (± 0.23%) 10.88s (± 0.40%) +0.02s (+ 0.16%) 10.77s 10.96s
TFS - node (v14.15.1, x64)
Memory used 289,222k (± 0.01%) 289,258k (± 0.01%) +37k (+ 0.01%) 289,226k 289,295k
Parse Time 1.24s (± 0.93%) 1.23s (± 0.87%) -0.01s (- 0.49%) 1.21s 1.26s
Bind Time 0.74s (± 0.80%) 0.74s (± 1.05%) -0.00s (- 0.40%) 0.72s 0.76s
Check Time 4.97s (± 0.46%) 4.96s (± 0.30%) -0.01s (- 0.16%) 4.93s 5.00s
Emit Time 3.55s (± 0.62%) 3.54s (± 0.47%) -0.01s (- 0.39%) 3.50s 3.57s
Total Time 10.50s (± 0.26%) 10.47s (± 0.34%) -0.03s (- 0.27%) 10.38s 10.54s
material-ui - node (v14.15.1, x64)
Memory used 448,793k (± 0.06%) 447,198k (± 0.01%) -1,596k (- 0.36%) 447,148k 447,230k
Parse Time 1.83s (± 0.38%) 1.84s (± 0.45%) +0.01s (+ 0.33%) 1.82s 1.85s
Bind Time 0.68s (± 0.53%) 0.68s (± 0.53%) -0.00s (- 0.00%) 0.68s 0.69s
Check Time 12.95s (± 0.56%) 12.82s (± 0.39%) -0.13s (- 1.01%) 12.72s 12.97s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.46s (± 0.45%) 15.34s (± 0.33%) -0.13s (- 0.81%) 15.25s 15.49s
xstate - node (v14.15.1, x64)
Memory used 534,116k (± 0.01%) 533,911k (± 0.00%) -205k (- 0.04%) 533,878k 533,939k
Parse Time 2.55s (± 0.55%) 2.55s (± 0.45%) -0.00s (- 0.08%) 2.53s 2.58s
Bind Time 1.16s (± 0.89%) 1.17s (± 0.65%) +0.00s (+ 0.26%) 1.16s 1.19s
Check Time 1.49s (± 0.56%) 1.47s (± 0.53%) -0.01s (- 0.94%) 1.46s 1.49s
Emit Time 0.08s (± 4.42%) 0.08s (± 4.42%) 0.00s ( 0.00%) 0.07s 0.08s
Total Time 5.28s (± 0.31%) 5.27s (± 0.36%) -0.01s (- 0.28%) 5.24s 5.31s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-210-generic
Architecturex64
Available Memory16 GB
Available Memory6 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v10.16.3, x64)
  • Compiler-Unions - node (v12.1.0, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v14.15.1, x64)
  • xstate - node (v10.16.3, x64)
  • xstate - node (v12.1.0, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 47738 10
Baseline main 10

Developer Information:

Download Benchmark

@ahejlsberg
Copy link
Member Author

@typescript-bot test this
@typescript-bot run dt
@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 4, 2022

Heya @ahejlsberg, I've started to run the perf test suite on this PR at f269f42. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 4, 2022

Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at f269f42. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 4, 2022

Heya @ahejlsberg, I've started to run the extended test suite on this PR at f269f42. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..47738

Metric main 47738 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 356,326k (± 0.02%) 356,306k (± 0.02%) -20k (- 0.01%) 356,168k 356,497k
Parse Time 1.96s (± 0.54%) 1.95s (± 0.28%) -0.00s (- 0.20%) 1.94s 1.97s
Bind Time 0.85s (± 0.70%) 0.86s (± 0.60%) +0.01s (+ 0.70%) 0.85s 0.87s
Check Time 5.62s (± 0.54%) 5.63s (± 0.66%) +0.01s (+ 0.20%) 5.56s 5.75s
Emit Time 5.91s (± 0.51%) 5.94s (± 0.77%) +0.03s (+ 0.54%) 5.84s 6.08s
Total Time 14.33s (± 0.36%) 14.38s (± 0.53%) +0.05s (+ 0.33%) 14.26s 14.63s
Compiler-Unions - node (v10.16.3, x64)
Memory used 204,231k (± 0.03%) 204,101k (± 0.03%) -130k (- 0.06%) 203,992k 204,266k
Parse Time 0.79s (± 0.76%) 0.79s (± 0.70%) +0.01s (+ 0.76%) 0.78s 0.80s
Bind Time 0.53s (± 1.30%) 0.53s (± 1.27%) +0.00s (+ 0.38%) 0.52s 0.54s
Check Time 7.87s (± 0.52%) 7.89s (± 0.50%) +0.02s (+ 0.25%) 7.81s 8.01s
Emit Time 2.48s (± 0.85%) 2.47s (± 0.97%) -0.01s (- 0.20%) 2.42s 2.53s
Total Time 11.65s (± 0.38%) 11.68s (± 0.42%) +0.03s (+ 0.23%) 11.58s 11.77s
Monaco - node (v10.16.3, x64)
Memory used 342,657k (± 0.02%) 342,666k (± 0.02%) +9k (+ 0.00%) 342,542k 342,899k
Parse Time 1.48s (± 0.42%) 1.48s (± 0.50%) -0.00s (- 0.07%) 1.46s 1.49s
Bind Time 0.76s (± 0.79%) 0.76s (± 0.73%) +0.01s (+ 0.93%) 0.75s 0.77s
Check Time 5.55s (± 0.61%) 5.52s (± 0.91%) -0.03s (- 0.58%) 5.44s 5.63s
Emit Time 3.21s (± 0.86%) 3.25s (± 1.06%) +0.04s (+ 1.09%) 3.19s 3.34s
Total Time 11.00s (± 0.32%) 11.01s (± 0.35%) +0.01s (+ 0.11%) 10.92s 11.08s
TFS - node (v10.16.3, x64)
Memory used 305,696k (± 0.02%) 305,741k (± 0.02%) +45k (+ 0.01%) 305,641k 305,823k
Parse Time 1.20s (± 0.51%) 1.20s (± 0.51%) +0.00s (+ 0.00%) 1.19s 1.21s
Bind Time 0.72s (± 0.62%) 0.72s (± 0.72%) -0.00s (- 0.14%) 0.71s 0.73s
Check Time 5.06s (± 0.67%) 5.08s (± 0.33%) +0.01s (+ 0.26%) 5.04s 5.12s
Emit Time 3.40s (± 0.76%) 3.40s (± 0.82%) -0.00s (- 0.06%) 3.35s 3.45s
Total Time 10.38s (± 0.37%) 10.39s (± 0.29%) +0.01s (+ 0.10%) 10.35s 10.49s
material-ui - node (v10.16.3, x64)
Memory used 471,934k (± 0.01%) 469,938k (± 0.02%) -1,996k (- 0.42%) 469,752k 470,066k
Parse Time 1.78s (± 0.53%) 1.78s (± 0.57%) -0.00s (- 0.06%) 1.76s 1.81s
Bind Time 0.66s (± 1.21%) 0.66s (± 1.37%) -0.00s (- 0.15%) 0.65s 0.68s
Check Time 14.25s (± 0.66%) 14.23s (± 0.44%) -0.02s (- 0.12%) 14.08s 14.35s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.69s (± 0.61%) 16.67s (± 0.39%) -0.02s (- 0.11%) 16.50s 16.79s
xstate - node (v10.16.3, x64)
Memory used 570,550k (± 0.02%) 573,824k (± 1.36%) +3,274k (+ 0.57%) 570,137k 605,388k
Parse Time 2.56s (± 0.34%) 2.56s (± 0.35%) -0.00s (- 0.08%) 2.53s 2.57s
Bind Time 1.01s (± 0.29%) 1.02s (± 0.58%) +0.01s (+ 0.79%) 1.01s 1.03s
Check Time 1.50s (± 0.55%) 1.49s (± 0.51%) -0.01s (- 0.80%) 1.47s 1.50s
Emit Time 0.07s (± 0.00%) 0.07s (± 3.14%) +0.00s (+ 1.43%) 0.07s 0.08s
Total Time 5.14s (± 0.28%) 5.12s (± 0.24%) -0.02s (- 0.33%) 5.10s 5.16s
Angular - node (v12.1.0, x64)
Memory used 333,906k (± 0.12%) 334,140k (± 0.02%) +233k (+ 0.07%) 334,036k 334,250k
Parse Time 1.95s (± 0.60%) 1.95s (± 0.74%) -0.00s (- 0.21%) 1.93s 2.00s
Bind Time 0.84s (± 0.86%) 0.84s (± 0.56%) +0.00s (+ 0.12%) 0.83s 0.85s
Check Time 5.42s (± 0.51%) 5.42s (± 0.46%) +0.00s (+ 0.00%) 5.35s 5.46s
Emit Time 6.14s (± 0.58%) 6.13s (± 0.56%) -0.00s (- 0.08%) 6.06s 6.22s
Total Time 14.35s (± 0.37%) 14.34s (± 0.46%) -0.01s (- 0.08%) 14.17s 14.47s
Compiler-Unions - node (v12.1.0, x64)
Memory used 191,771k (± 0.04%) 191,409k (± 0.14%) -362k (- 0.19%) 190,500k 191,733k
Parse Time 0.78s (± 0.74%) 0.78s (± 0.63%) -0.00s (- 0.51%) 0.77s 0.79s
Bind Time 0.54s (± 0.69%) 0.53s (± 1.09%) -0.00s (- 0.37%) 0.52s 0.55s
Check Time 7.32s (± 0.40%) 7.33s (± 0.55%) +0.00s (+ 0.01%) 7.26s 7.41s
Emit Time 2.48s (± 0.91%) 2.49s (± 0.66%) +0.01s (+ 0.28%) 2.47s 2.54s
Total Time 11.12s (± 0.30%) 11.13s (± 0.30%) +0.00s (+ 0.04%) 11.05s 11.19s
Monaco - node (v12.1.0, x64)
Memory used 325,727k (± 0.02%) 325,751k (± 0.02%) +24k (+ 0.01%) 325,665k 325,880k
Parse Time 1.46s (± 0.72%) 1.47s (± 0.93%) +0.01s (+ 0.41%) 1.45s 1.51s
Bind Time 0.74s (± 0.91%) 0.74s (± 0.78%) -0.00s (- 0.13%) 0.73s 0.76s
Check Time 5.44s (± 0.60%) 5.44s (± 0.55%) -0.01s (- 0.11%) 5.37s 5.52s
Emit Time 3.26s (± 0.95%) 3.23s (± 0.59%) -0.02s (- 0.74%) 3.20s 3.26s
Total Time 10.90s (± 0.37%) 10.88s (± 0.34%) -0.03s (- 0.24%) 10.77s 10.94s
TFS - node (v12.1.0, x64)
Memory used 290,444k (± 0.02%) 290,390k (± 0.02%) -54k (- 0.02%) 290,251k 290,529k
Parse Time 1.21s (± 0.66%) 1.21s (± 0.53%) +0.00s (+ 0.33%) 1.20s 1.22s
Bind Time 0.70s (± 1.23%) 0.70s (± 0.72%) -0.01s (- 1.00%) 0.69s 0.71s
Check Time 4.99s (± 0.40%) 4.99s (± 0.42%) 0.00s ( 0.00%) 4.94s 5.03s
Emit Time 3.44s (± 0.47%) 3.43s (± 1.20%) -0.01s (- 0.20%) 3.35s 3.54s
Total Time 10.34s (± 0.22%) 10.33s (± 0.51%) -0.01s (- 0.07%) 10.20s 10.45s
material-ui - node (v12.1.0, x64)
Memory used 450,679k (± 0.01%) 448,845k (± 0.01%) -1,834k (- 0.41%) 448,656k 448,963k
Parse Time 1.78s (± 0.33%) 1.79s (± 0.49%) +0.01s (+ 0.56%) 1.77s 1.81s
Bind Time 0.64s (± 0.53%) 0.64s (± 0.69%) -0.00s (- 0.16%) 0.63s 0.65s
Check Time 12.82s (± 0.75%) 12.81s (± 0.77%) -0.01s (- 0.08%) 12.62s 13.02s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.24s (± 0.65%) 15.24s (± 0.63%) 0.00s ( 0.00%) 15.05s 15.44s
xstate - node (v12.1.0, x64)
Memory used 536,436k (± 0.02%) 543,126k (± 1.89%) +6,690k (+ 1.25%) 536,063k 570,783k
Parse Time 2.51s (± 0.74%) 2.49s (± 0.41%) -0.02s (- 0.84%) 2.47s 2.52s
Bind Time 1.05s (± 0.63%) 1.05s (± 0.72%) +0.00s (+ 0.09%) 1.04s 1.07s
Check Time 1.44s (± 0.61%) 1.43s (± 0.58%) -0.01s (- 0.62%) 1.42s 1.46s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.07s (± 0.34%) 5.05s (± 0.22%) -0.03s (- 0.51%) 5.02s 5.07s
Angular - node (v14.15.1, x64)
Memory used 332,364k (± 0.00%) 332,374k (± 0.01%) +10k (+ 0.00%) 332,342k 332,437k
Parse Time 1.95s (± 0.68%) 1.95s (± 0.53%) -0.01s (- 0.31%) 1.93s 1.98s
Bind Time 0.89s (± 0.79%) 0.89s (± 0.65%) +0.00s (+ 0.11%) 0.88s 0.91s
Check Time 5.45s (± 0.33%) 5.48s (± 0.56%) +0.04s (+ 0.70%) 5.41s 5.54s
Emit Time 6.20s (± 0.53%) 6.21s (± 0.78%) +0.01s (+ 0.15%) 6.11s 6.30s
Total Time 14.49s (± 0.25%) 14.53s (± 0.49%) +0.04s (+ 0.26%) 14.36s 14.65s
Compiler-Unions - node (v14.15.1, x64)
Memory used 192,663k (± 0.57%) 192,491k (± 0.57%) -173k (- 0.09%) 190,246k 193,526k
Parse Time 0.81s (± 0.64%) 0.81s (± 0.64%) 0.00s ( 0.00%) 0.80s 0.82s
Bind Time 0.56s (± 0.71%) 0.56s (± 0.80%) -0.00s (- 0.53%) 0.55s 0.57s
Check Time 7.41s (± 0.53%) 7.48s (± 0.89%) +0.07s (+ 0.89%) 7.38s 7.62s
Emit Time 2.50s (± 1.17%) 2.47s (± 0.58%) -0.03s (- 1.20%) 2.44s 2.52s
Total Time 11.28s (± 0.59%) 11.31s (± 0.58%) +0.03s (+ 0.30%) 11.21s 11.45s
Monaco - node (v14.15.1, x64)
Memory used 324,512k (± 0.00%) 324,513k (± 0.00%) +2k (+ 0.00%) 324,478k 324,544k
Parse Time 1.50s (± 0.50%) 1.50s (± 0.30%) +0.00s (+ 0.13%) 1.49s 1.51s
Bind Time 0.77s (± 0.72%) 0.77s (± 0.38%) -0.00s (- 0.00%) 0.77s 0.78s
Check Time 5.38s (± 0.62%) 5.37s (± 0.41%) -0.00s (- 0.07%) 5.32s 5.42s
Emit Time 3.30s (± 0.94%) 3.29s (± 0.52%) -0.01s (- 0.15%) 3.24s 3.32s
Total Time 10.94s (± 0.58%) 10.94s (± 0.28%) -0.01s (- 0.06%) 10.83s 11.00s
TFS - node (v14.15.1, x64)
Memory used 289,218k (± 0.01%) 289,239k (± 0.01%) +21k (+ 0.01%) 289,200k 289,309k
Parse Time 1.23s (± 0.81%) 1.23s (± 0.66%) 0.00s ( 0.00%) 1.21s 1.25s
Bind Time 0.74s (± 0.78%) 0.74s (± 0.60%) +0.00s (+ 0.27%) 0.73s 0.75s
Check Time 4.98s (± 0.44%) 4.97s (± 0.42%) -0.01s (- 0.16%) 4.94s 5.03s
Emit Time 3.55s (± 0.73%) 3.54s (± 0.68%) -0.00s (- 0.11%) 3.48s 3.60s
Total Time 10.50s (± 0.42%) 10.49s (± 0.38%) -0.01s (- 0.11%) 10.41s 10.58s
material-ui - node (v14.15.1, x64)
Memory used 448,902k (± 0.01%) 447,159k (± 0.00%) -1,743k (- 0.39%) 447,111k 447,210k
Parse Time 1.84s (± 0.58%) 1.83s (± 0.73%) -0.01s (- 0.38%) 1.81s 1.86s
Bind Time 0.68s (± 0.73%) 0.68s (± 0.50%) -0.00s (- 0.29%) 0.68s 0.69s
Check Time 12.96s (± 0.55%) 12.86s (± 0.46%) -0.10s (- 0.73%) 12.77s 13.08s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.48s (± 0.49%) 15.38s (± 0.41%) -0.10s (- 0.66%) 15.28s 15.61s
xstate - node (v14.15.1, x64)
Memory used 534,082k (± 0.00%) 533,917k (± 0.00%) -165k (- 0.03%) 533,882k 533,952k
Parse Time 2.56s (± 0.57%) 2.56s (± 0.71%) +0.01s (+ 0.20%) 2.54s 2.63s
Bind Time 1.16s (± 0.48%) 1.17s (± 1.18%) +0.00s (+ 0.26%) 1.15s 1.21s
Check Time 1.48s (± 0.60%) 1.48s (± 0.65%) -0.01s (- 0.61%) 1.46s 1.51s
Emit Time 0.08s (± 0.00%) 0.07s (± 3.14%) 🟩-0.01s (-11.25%) 0.07s 0.08s
Total Time 5.29s (± 0.26%) 5.28s (± 0.37%) -0.00s (- 0.06%) 5.25s 5.33s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-210-generic
Architecturex64
Available Memory16 GB
Available Memory6 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v10.16.3, x64)
  • Compiler-Unions - node (v12.1.0, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v14.15.1, x64)
  • xstate - node (v10.16.3, x64)
  • xstate - node (v12.1.0, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 47738 10
Baseline main 10

Developer Information:

Download Benchmark

@ahejlsberg
Copy link
Member Author

@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 5, 2022

Heya @ahejlsberg, I've started to run the perf test suite on this PR at 9404e06. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 5, 2022

Heya @ahejlsberg, I've started to run the abridged perf test suite on this PR at 9404e06. You can monitor the build here.

Update: The results are in!

@ahejlsberg
Copy link
Member Author

@typescript-bot test this
@typescript-bot user test this inline
@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 5, 2022

Heya @ahejlsberg, I've started to run the diff-based community code test suite on this PR at 9404e06. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 5, 2022

Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 9404e06. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 5, 2022

Heya @ahejlsberg, I've started to run the extended test suite on this PR at 9404e06. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 8, 2022

Heya @ahejlsberg, I've started to run the abridged perf test suite on this PR at 25a71c4. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..47738

Metric main 47738 Delta Best Worst
Angular - node (v14.15.1, x64)
Memory used 332,356k (± 0.00%) 332,333k (± 0.08%) -23k (- 0.01%) 331,215k 332,500k
Parse Time 1.95s (± 0.42%) 1.95s (± 0.34%) -0.01s (- 0.31%) 1.93s 1.96s
Bind Time 0.89s (± 0.67%) 0.89s (± 0.85%) 0.00s ( 0.00%) 0.87s 0.90s
Check Time 5.44s (± 0.28%) 5.41s (± 0.69%) -0.03s (- 0.59%) 5.34s 5.50s
Emit Time 6.16s (± 0.59%) 6.23s (± 1.02%) +0.07s (+ 1.07%) 6.15s 6.46s
Total Time 14.44s (± 0.22%) 14.47s (± 0.62%) +0.03s (+ 0.20%) 14.37s 14.77s
Compiler-Unions - node (v14.15.1, x64)
Memory used 191,997k (± 0.62%) 193,816k (± 0.55%) +1,820k (+ 0.95%) 191,591k 194,843k
Parse Time 0.81s (± 0.42%) 0.81s (± 0.46%) -0.00s (- 0.25%) 0.80s 0.81s
Bind Time 0.56s (± 0.65%) 0.56s (± 1.15%) +0.01s (+ 1.08%) 0.55s 0.58s
Check Time 7.41s (± 0.61%) 7.26s (± 0.99%) -0.15s (- 1.97%) 7.16s 7.51s
Emit Time 2.48s (± 0.83%) 2.50s (± 1.03%) +0.02s (+ 0.73%) 2.45s 2.57s
Total Time 11.25s (± 0.42%) 11.13s (± 0.62%) -0.12s (- 1.08%) 11.01s 11.36s
Monaco - node (v14.15.1, x64)
Memory used 324,513k (± 0.01%) 324,504k (± 0.00%) -9k (- 0.00%) 324,481k 324,534k
Parse Time 1.50s (± 0.47%) 1.50s (± 0.54%) +0.00s (+ 0.13%) 1.49s 1.52s
Bind Time 0.77s (± 0.68%) 0.77s (± 1.01%) +0.00s (+ 0.26%) 0.76s 0.79s
Check Time 5.35s (± 0.35%) 5.27s (± 0.26%) -0.08s (- 1.48%) 5.25s 5.30s
Emit Time 3.26s (± 0.48%) 3.29s (± 0.86%) +0.03s (+ 0.83%) 3.22s 3.36s
Total Time 10.88s (± 0.24%) 10.83s (± 0.34%) -0.05s (- 0.42%) 10.74s 10.92s
TFS - node (v14.15.1, x64)
Memory used 289,239k (± 0.01%) 289,244k (± 0.01%) +5k (+ 0.00%) 289,185k 289,302k
Parse Time 1.24s (± 0.67%) 1.23s (± 0.60%) -0.01s (- 0.49%) 1.21s 1.24s
Bind Time 0.74s (± 0.65%) 0.74s (± 0.95%) +0.00s (+ 0.27%) 0.73s 0.76s
Check Time 4.98s (± 0.51%) 4.95s (± 0.47%) -0.03s (- 0.70%) 4.91s 5.01s
Emit Time 3.55s (± 0.55%) 3.56s (± 0.61%) +0.01s (+ 0.42%) 3.52s 3.61s
Total Time 10.50s (± 0.34%) 10.47s (± 0.35%) -0.03s (- 0.24%) 10.40s 10.59s
material-ui - node (v14.15.1, x64)
Memory used 448,883k (± 0.00%) 446,011k (± 0.00%) -2,872k (- 0.64%) 445,942k 446,046k
Parse Time 1.83s (± 0.30%) 1.84s (± 0.63%) +0.01s (+ 0.38%) 1.81s 1.86s
Bind Time 0.68s (± 0.54%) 0.69s (± 0.50%) +0.00s (+ 0.29%) 0.68s 0.69s
Check Time 12.85s (± 0.45%) 12.69s (± 0.84%) -0.16s (- 1.25%) 12.56s 13.07s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.36s (± 0.40%) 15.21s (± 0.67%) -0.15s (- 0.97%) 15.08s 15.57s
xstate - node (v14.15.1, x64)
Memory used 534,107k (± 0.01%) 533,927k (± 0.01%) -180k (- 0.03%) 533,867k 534,021k
Parse Time 2.56s (± 0.62%) 2.55s (± 0.57%) -0.02s (- 0.59%) 2.52s 2.59s
Bind Time 1.18s (± 2.27%) 1.17s (± 0.76%) -0.01s (- 1.02%) 1.15s 1.19s
Check Time 1.49s (± 1.82%) 1.45s (± 0.48%) -0.04s (- 2.75%) 1.44s 1.47s
Emit Time 0.08s (± 0.00%) 0.08s (± 3.81%) -0.00s (- 2.50%) 0.07s 0.08s
Total Time 5.32s (± 1.20%) 5.24s (± 0.31%) -0.08s (- 1.47%) 5.22s 5.29s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-210-generic
Architecturex64
Available Memory16 GB
Available Memory6 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v14.15.1, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 47738 10
Baseline main 10

Developer Information:

Download Benchmark

@RyanCavanaugh
Copy link
Member

I haven't looked over the checker code thoroughly, but all the baseline diffs are either positive or equivalently OK IMO

Copy link
Member

@DanielRosenwasser DanielRosenwasser left a comment

Choose a reason for hiding this comment

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

Mostly looks good. I think some comments do need to be updated, and there are some style suggestions. I am glad to see the error heuristics pick up more consistently!

};
}

function reportIncompatibleError(message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number) {
overrideNextErrorInfo++; // Suppress the next relation error
lastSkippedInfo = undefined; // Reset skipped info cache
incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
(incompatibleStack || (incompatibleStack = [])).push([message, arg0, arg1, arg2, arg3]);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
(incompatibleStack || (incompatibleStack = [])).push([message, arg0, arg1, arg2, arg3]);
(incompatibleStack ||= []).push([message, arg0, arg1, arg2, arg3]);

@@ -17998,21 +17997,21 @@ namespace ts {
return {
errorInfo,
lastSkippedInfo,
incompatibleStack: incompatibleStack.slice(),
incompatibleStack: incompatibleStack ? incompatibleStack.slice() : undefined,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
incompatibleStack: incompatibleStack ? incompatibleStack.slice() : undefined,
incompatibleStack: incompatibleStack?.slice(),

or

Suggested change
incompatibleStack: incompatibleStack ? incompatibleStack.slice() : undefined,
incompatibleStack: incompatibleStack && incompatibleStack.slice(),

overrideNextErrorInfo,
relatedInfo: !relatedInfo ? undefined : relatedInfo.slice() as ([DiagnosticRelatedInformation, ...DiagnosticRelatedInformation[]] | undefined)
relatedInfo: relatedInfo ? relatedInfo.slice() as [DiagnosticRelatedInformation, ...DiagnosticRelatedInformation[]] : undefined,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
relatedInfo: relatedInfo ? relatedInfo.slice() as [DiagnosticRelatedInformation, ...DiagnosticRelatedInformation[]] : undefined,
relatedInfo: relatedInfo?.slice() as [DiagnosticRelatedInformation, ...DiagnosticRelatedInformation[]] | undefined,

src/compiler/checker.ts Outdated Show resolved Hide resolved
Comment on lines 18584 to 18585
// useful and leads to some confusing error messages. Instead it is better to let the below checks
// take care of this, or to not elaborate at all. For instance,
Copy link
Member

Choose a reason for hiding this comment

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

Instead it is better to let the below checks take care of this, or to not elaborate at all.

Those below checks no longer exist :D

Instead, I guess you have to comment that you're expecting callers to handle elaboration on intersection types.

Comment on lines 18575 to 18576
source = getIntersectionType(constraints);
if (!(source.flags & TypeFlags.Intersection)) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
source = getIntersectionType(constraints);
if (!(source.flags & TypeFlags.Intersection)) {
// At this point we're only interested in constraints of the intersection,
// either here or in further checks on the apparent type below.
source = getIntersectionType(constraints);
if (!(source.flags & TypeFlags.Intersection)) {

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, this is just handling the case where the intersection gets reduced down to a singleton type.

Copy link
Member

@DanielRosenwasser DanielRosenwasser Feb 9, 2022

Choose a reason for hiding this comment

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

This is the part that's handling the cases where the intersection of constraints could be a singleton (or technically a primitive or union), but you're changing source for the intersection case below as well, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but the comment above the whole section already says that we're hoisting the constraints into a new intersection (with the implication that it replaces the old source). But perhaps that isn't clear enough.

Comment on lines 18295 to 18296
// See if we're relating a definitely non-nullable type to a union that includes null and/or undefined
// plus a single non-nullable type. If so, remove null and/or undefined from the target type.
Copy link
Member

Choose a reason for hiding this comment

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

I actually slightly prefer the old comment, but I'm not opposed to this.

@DanielRosenwasser
Copy link
Member

The PR also optimizies the isRelatedTo function by moving more work to the cached side on relationship checking.

Can you elaborate on that? I saw that you did hoist a bunch of source.flags and target.flags around in a few functions which we've heard might be a helpful optimization, but I'm not picking up what you're referring to.

@ahejlsberg
Copy link
Member Author

Can you elaborate on that?

In general, logic that sits in isRelatedTo is on the uncached side and logic that sits in structuredTypeRelatedTo is on the cached side (by way of recursiveTypeRelatedTo). The PR makes the following optimizations:

  • Some logic is moved from isRelatedTo to structuredTypeRelatedTo, ensuring that we only execute it once for a given pair of types.
  • The isRelatedTo function would often make two calls to recursiveTypeRelatedTo in order to check relations involving unions or intersections. That incurred the cost of computing keys and checking the relation cache twice. We now only call recursiveTypeRelatedTo once for a given pair of types.
  • The reportErrorResults function is un-nested such that closures don't get allocated in isRelatedTo.
  • The captureErrorCalculationState function is no longer called by isRelatedTo which cuts down on garbage.

We could further consider moving the excess and common property checking code to the cached side, though it isn't run all that often and would require some restructuring in structuredTypeRelatedTo.

@DanielRosenwasser
Copy link
Member

@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 10, 2022

Heya @DanielRosenwasser, I've started to run the perf test suite on this PR at 1d70b01. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..47738

Metric main 47738 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 356,345k (± 0.02%) 356,491k (± 0.02%) +145k (+ 0.04%) 356,332k 356,750k
Parse Time 1.96s (± 0.34%) 1.95s (± 0.57%) -0.00s (- 0.10%) 1.93s 1.98s
Bind Time 0.85s (± 0.43%) 0.85s (± 0.56%) -0.00s (- 0.23%) 0.84s 0.86s
Check Time 5.64s (± 0.49%) 5.58s (± 0.44%) -0.06s (- 1.12%) 5.54s 5.64s
Emit Time 5.90s (± 0.52%) 5.90s (± 0.63%) -0.00s (- 0.05%) 5.84s 5.98s
Total Time 14.35s (± 0.35%) 14.28s (± 0.36%) -0.07s (- 0.52%) 14.20s 14.44s
Compiler-Unions - node (v10.16.3, x64)
Memory used 204,316k (± 0.03%) 205,381k (± 0.04%) +1,065k (+ 0.52%) 205,198k 205,559k
Parse Time 0.78s (± 0.83%) 0.78s (± 1.05%) +0.00s (+ 0.26%) 0.77s 0.81s
Bind Time 0.53s (± 1.09%) 0.53s (± 0.65%) -0.00s (- 0.57%) 0.52s 0.53s
Check Time 7.91s (± 0.73%) 7.65s (± 0.26%) 🟩-0.26s (- 3.26%) 7.63s 7.71s
Emit Time 2.48s (± 1.43%) 2.46s (± 0.33%) -0.02s (- 0.77%) 2.44s 2.47s
Total Time 11.70s (± 0.65%) 11.43s (± 0.21%) -0.28s (- 2.38%) 11.40s 11.50s
Monaco - node (v10.16.3, x64)
Memory used 342,742k (± 0.02%) 342,681k (± 0.02%) -60k (- 0.02%) 342,571k 342,797k
Parse Time 1.49s (± 0.51%) 1.48s (± 0.45%) -0.00s (- 0.13%) 1.47s 1.50s
Bind Time 0.75s (± 0.66%) 0.76s (± 0.59%) +0.00s (+ 0.40%) 0.75s 0.77s
Check Time 5.59s (± 0.53%) 5.50s (± 0.44%) -0.08s (- 1.52%) 5.46s 5.58s
Emit Time 3.24s (± 0.91%) 3.23s (± 1.31%) -0.01s (- 0.22%) 3.16s 3.37s
Total Time 11.07s (± 0.18%) 10.97s (± 0.34%) -0.09s (- 0.81%) 10.90s 11.08s
TFS - node (v10.16.3, x64)
Memory used 305,761k (± 0.01%) 305,779k (± 0.02%) +19k (+ 0.01%) 305,678k 305,953k
Parse Time 1.20s (± 0.62%) 1.20s (± 0.68%) +0.00s (+ 0.00%) 1.19s 1.22s
Bind Time 0.72s (± 0.93%) 0.72s (± 0.66%) -0.00s (- 0.00%) 0.71s 0.73s
Check Time 5.10s (± 0.46%) 5.08s (± 0.29%) -0.02s (- 0.45%) 5.05s 5.11s
Emit Time 3.42s (± 1.95%) 3.38s (± 1.16%) -0.04s (- 1.26%) 3.30s 3.47s
Total Time 10.43s (± 0.63%) 10.37s (± 0.43%) -0.06s (- 0.59%) 10.27s 10.48s
material-ui - node (v10.16.3, x64)
Memory used 472,054k (± 0.01%) 468,742k (± 0.01%) -3,312k (- 0.70%) 468,669k 468,830k
Parse Time 1.77s (± 0.34%) 1.77s (± 0.37%) -0.00s (- 0.17%) 1.76s 1.78s
Bind Time 0.66s (± 1.06%) 0.66s (± 0.89%) +0.01s (+ 0.76%) 0.65s 0.68s
Check Time 14.34s (± 0.39%) 14.01s (± 0.48%) -0.33s (- 2.32%) 13.87s 14.14s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.77s (± 0.36%) 16.44s (± 0.42%) -0.34s (- 2.00%) 16.31s 16.58s
xstate - node (v10.16.3, x64)
Memory used 574,283k (± 1.39%) 570,377k (± 0.02%) -3,906k (- 0.68%) 570,108k 570,618k
Parse Time 2.55s (± 0.32%) 2.55s (± 0.35%) +0.00s (+ 0.04%) 2.53s 2.58s
Bind Time 1.01s (± 0.49%) 1.01s (± 0.36%) 0.00s ( 0.00%) 1.01s 1.02s
Check Time 1.52s (± 0.49%) 1.47s (± 0.40%) 🟩-0.05s (- 3.03%) 1.46s 1.48s
Emit Time 0.07s (± 0.00%) 0.07s (± 3.14%) +0.00s (+ 1.43%) 0.07s 0.08s
Total Time 5.16s (± 0.22%) 5.11s (± 0.24%) -0.05s (- 0.91%) 5.09s 5.15s
Angular - node (v12.1.0, x64)
Memory used 334,075k (± 0.03%) 334,252k (± 0.02%) +176k (+ 0.05%) 334,113k 334,448k
Parse Time 1.94s (± 0.31%) 1.95s (± 0.75%) +0.00s (+ 0.26%) 1.93s 2.00s
Bind Time 0.84s (± 1.06%) 0.84s (± 0.74%) -0.01s (- 0.71%) 0.82s 0.85s
Check Time 5.45s (± 0.47%) 5.42s (± 0.51%) -0.02s (- 0.39%) 5.37s 5.49s
Emit Time 6.19s (± 0.80%) 6.14s (± 0.56%) -0.05s (- 0.78%) 6.06s 6.25s
Total Time 14.42s (± 0.48%) 14.36s (± 0.41%) -0.07s (- 0.46%) 14.25s 14.54s
Compiler-Unions - node (v12.1.0, x64)
Memory used 191,810k (± 0.03%) 192,822k (± 0.08%) +1,011k (+ 0.53%) 192,423k 192,960k
Parse Time 0.78s (± 0.71%) 0.78s (± 0.71%) +0.00s (+ 0.51%) 0.77s 0.79s
Bind Time 0.53s (± 1.25%) 0.54s (± 0.93%) +0.00s (+ 0.38%) 0.52s 0.54s
Check Time 7.36s (± 0.45%) 7.12s (± 0.40%) 🟩-0.23s (- 3.17%) 7.05s 7.18s
Emit Time 2.48s (± 0.46%) 2.51s (± 1.47%) +0.03s (+ 1.21%) 2.46s 2.62s
Total Time 11.16s (± 0.32%) 10.96s (± 0.48%) -0.20s (- 1.77%) 10.87s 11.11s
Monaco - node (v12.1.0, x64)
Memory used 325,691k (± 0.03%) 325,597k (± 0.07%) -94k (- 0.03%) 324,670k 325,808k
Parse Time 1.47s (± 0.63%) 1.47s (± 1.07%) -0.01s (- 0.41%) 1.43s 1.50s
Bind Time 0.74s (± 0.78%) 0.74s (± 0.90%) +0.00s (+ 0.41%) 0.73s 0.76s
Check Time 5.45s (± 0.32%) 5.39s (± 0.28%) -0.06s (- 1.05%) 5.36s 5.41s
Emit Time 3.26s (± 0.89%) 3.24s (± 0.69%) -0.01s (- 0.40%) 3.21s 3.31s
Total Time 10.91s (± 0.30%) 10.84s (± 0.37%) -0.07s (- 0.68%) 10.75s 10.93s
TFS - node (v12.1.0, x64)
Memory used 290,423k (± 0.02%) 290,422k (± 0.02%) -1k (- 0.00%) 290,335k 290,641k
Parse Time 1.22s (± 0.49%) 1.21s (± 1.03%) -0.00s (- 0.16%) 1.19s 1.25s
Bind Time 0.70s (± 0.68%) 0.70s (± 0.88%) +0.00s (+ 0.29%) 0.69s 0.71s
Check Time 5.02s (± 0.60%) 4.98s (± 0.46%) -0.04s (- 0.80%) 4.95s 5.04s
Emit Time 3.44s (± 0.89%) 3.44s (± 0.81%) +0.01s (+ 0.20%) 3.37s 3.48s
Total Time 10.37s (± 0.52%) 10.34s (± 0.37%) -0.04s (- 0.35%) 10.25s 10.40s
material-ui - node (v12.1.0, x64)
Memory used 450,474k (± 0.09%) 447,855k (± 0.02%) -2,620k (- 0.58%) 447,700k 447,994k
Parse Time 1.78s (± 0.55%) 1.78s (± 0.32%) +0.00s (+ 0.11%) 1.77s 1.79s
Bind Time 0.64s (± 0.87%) 0.64s (± 0.46%) 0.00s ( 0.00%) 0.64s 0.65s
Check Time 12.86s (± 0.63%) 12.66s (± 0.58%) -0.20s (- 1.52%) 12.53s 12.86s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.28s (± 0.53%) 15.09s (± 0.48%) -0.19s (- 1.26%) 14.96s 15.28s
xstate - node (v12.1.0, x64)
Memory used 536,615k (± 0.02%) 536,288k (± 0.02%) -327k (- 0.06%) 536,116k 536,487k
Parse Time 2.49s (± 0.42%) 2.49s (± 0.27%) +0.00s (+ 0.16%) 2.48s 2.51s
Bind Time 1.05s (± 0.55%) 1.04s (± 0.66%) -0.01s (- 0.48%) 1.03s 1.06s
Check Time 1.46s (± 0.46%) 1.42s (± 0.41%) -0.04s (- 2.54%) 1.41s 1.44s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.06s (± 0.21%) 5.03s (± 0.20%) -0.03s (- 0.63%) 5.01s 5.05s
Angular - node (v14.15.1, x64)
Memory used 332,392k (± 0.01%) 332,488k (± 0.00%) +96k (+ 0.03%) 332,459k 332,521k
Parse Time 1.95s (± 0.51%) 1.95s (± 0.56%) 0.00s ( 0.00%) 1.93s 1.98s
Bind Time 0.89s (± 0.85%) 0.88s (± 0.83%) -0.00s (- 0.45%) 0.87s 0.90s
Check Time 5.47s (± 0.29%) 5.44s (± 0.45%) -0.03s (- 0.62%) 5.38s 5.50s
Emit Time 6.19s (± 0.75%) 6.17s (± 0.75%) -0.02s (- 0.31%) 6.11s 6.32s
Total Time 14.50s (± 0.37%) 14.44s (± 0.36%) -0.06s (- 0.42%) 14.35s 14.57s
Compiler-Unions - node (v14.15.1, x64)
Memory used 193,006k (± 0.49%) 194,018k (± 0.57%) +1,012k (+ 0.52%) 190,530k 194,819k
Parse Time 0.81s (± 0.59%) 0.81s (± 0.73%) +0.01s (+ 0.87%) 0.80s 0.83s
Bind Time 0.56s (± 0.40%) 0.56s (± 0.72%) 0.00s ( 0.00%) 0.55s 0.57s
Check Time 7.43s (± 0.35%) 7.27s (± 0.57%) -0.16s (- 2.18%) 7.18s 7.37s
Emit Time 2.48s (± 0.63%) 2.46s (± 0.76%) -0.02s (- 0.69%) 2.43s 2.51s
Total Time 11.27s (± 0.28%) 11.10s (± 0.41%) -0.17s (- 1.51%) 11.03s 11.20s
Monaco - node (v14.15.1, x64)
Memory used 324,514k (± 0.00%) 324,494k (± 0.01%) -21k (- 0.01%) 324,448k 324,536k
Parse Time 1.50s (± 0.51%) 1.50s (± 0.47%) -0.01s (- 0.40%) 1.49s 1.52s
Bind Time 0.77s (± 0.75%) 0.77s (± 0.84%) +0.00s (+ 0.26%) 0.76s 0.79s
Check Time 5.39s (± 0.49%) 5.31s (± 0.49%) -0.08s (- 1.47%) 5.27s 5.38s
Emit Time 3.27s (± 0.29%) 3.28s (± 0.67%) +0.01s (+ 0.37%) 3.25s 3.35s
Total Time 10.94s (± 0.33%) 10.87s (± 0.27%) -0.07s (- 0.66%) 10.79s 10.93s
TFS - node (v14.15.1, x64)
Memory used 289,257k (± 0.01%) 289,250k (± 0.01%) -7k (- 0.00%) 289,183k 289,288k
Parse Time 1.23s (± 0.56%) 1.23s (± 0.77%) +0.01s (+ 0.82%) 1.21s 1.25s
Bind Time 0.74s (± 0.70%) 0.74s (± 0.54%) 0.00s ( 0.00%) 0.73s 0.75s
Check Time 5.01s (± 0.47%) 5.00s (± 0.40%) -0.01s (- 0.30%) 4.93s 5.03s
Emit Time 3.53s (± 0.58%) 3.55s (± 0.46%) +0.02s (+ 0.57%) 3.51s 3.59s
Total Time 10.51s (± 0.32%) 10.52s (± 0.31%) +0.01s (+ 0.12%) 10.43s 10.58s
material-ui - node (v14.15.1, x64)
Memory used 448,907k (± 0.01%) 446,046k (± 0.01%) -2,860k (- 0.64%) 446,011k 446,108k
Parse Time 1.83s (± 0.48%) 1.83s (± 0.61%) +0.00s (+ 0.05%) 1.82s 1.87s
Bind Time 0.68s (± 0.54%) 0.68s (± 0.70%) -0.00s (- 0.29%) 0.67s 0.69s
Check Time 12.99s (± 0.55%) 12.70s (± 0.29%) -0.30s (- 2.29%) 12.61s 12.77s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.51s (± 0.43%) 15.21s (± 0.25%) -0.30s (- 1.91%) 15.15s 15.30s
xstate - node (v14.15.1, x64)
Memory used 534,354k (± 0.00%) 534,051k (± 0.00%) -303k (- 0.06%) 533,980k 534,094k
Parse Time 2.56s (± 0.35%) 2.56s (± 0.37%) 0.00s ( 0.00%) 2.54s 2.57s
Bind Time 1.17s (± 0.63%) 1.16s (± 0.86%) -0.01s (- 0.60%) 1.14s 1.18s
Check Time 1.50s (± 0.59%) 1.46s (± 0.34%) 🟩-0.05s (- 3.26%) 1.45s 1.47s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.31s (± 0.33%) 5.26s (± 0.25%) -0.05s (- 1.02%) 5.23s 5.28s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-210-generic
Architecturex64
Available Memory16 GB
Available Memory6 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v10.16.3, x64)
  • Compiler-Unions - node (v12.1.0, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v14.15.1, x64)
  • xstate - node (v10.16.3, x64)
  • xstate - node (v12.1.0, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 47738 10
Baseline main 10

Developer Information:

Download Benchmark

Copy link
Member

@DanielRosenwasser DanielRosenwasser left a comment

Choose a reason for hiding this comment

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

Seems like a really good change! Let's get it in after the 4.6 RC gets finalized.

@mrpmorris

This comment was marked as off-topic.

# Conflicts:
#	src/compiler/diagnosticMessages.json
@ahejlsberg ahejlsberg merged commit 44e827b into main Feb 15, 2022
@ahejlsberg ahejlsberg deleted the fix47668 branch February 15, 2022 18:30
@RyanCavanaugh
Copy link
Member

@typescript-bot cherry-pick this to release-4.6

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 15, 2022

Heya @RyanCavanaugh, I've started to run the task to cherry-pick this into release-4.6 on this PR at c472ba5. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

Hey @RyanCavanaugh, I've opened #47907 for you.

typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request Feb 15, 2022
Component commits:
628da10 Eliminate redundant or meaningless elaborations in type relations

a009ee1 Accept new baselines

a65794c Add resetErrorInfo (though, oddly, shouldn't be necessary)

f269f42 Less aggressive reduction in second pass union/intersection checks

1312e8a Accept new baselines

b82966f Restructure and back off a little bit more

f0b8742 Only cache union/intersection relations once

9404e06 Accept new baselines

4866ce5 Properly cache identity relations, clean up error reporting

2670b26 Move more logic to cached side of relation checks

adb37a5 Optimize and remove more redundant elaborations

16b986b Accept new baselines

1c69acb Remove unnecessary error state capture

530c876 More optimizing

25a71c4 Cache isWeakType computation

c427a46 Revert "Cache isWeakType computation"
This reverts commit 25a71c4.

1d70b01 Address CR feedback

28439f7 Merge branch 'main' into fix47668
# Conflicts:
#	src/compiler/diagnosticMessages.json

c472ba5 Accept new baselines
DanielRosenwasser pushed a commit that referenced this pull request Feb 18, 2022
Component commits:
628da10 Eliminate redundant or meaningless elaborations in type relations

a009ee1 Accept new baselines

a65794c Add resetErrorInfo (though, oddly, shouldn't be necessary)

f269f42 Less aggressive reduction in second pass union/intersection checks

1312e8a Accept new baselines

b82966f Restructure and back off a little bit more

f0b8742 Only cache union/intersection relations once

9404e06 Accept new baselines

4866ce5 Properly cache identity relations, clean up error reporting

2670b26 Move more logic to cached side of relation checks

adb37a5 Optimize and remove more redundant elaborations

16b986b Accept new baselines

1c69acb Remove unnecessary error state capture

530c876 More optimizing

25a71c4 Cache isWeakType computation

c427a46 Revert "Cache isWeakType computation"
This reverts commit 25a71c4.

1d70b01 Address CR feedback

28439f7 Merge branch 'main' into fix47668
# Conflicts:
#	src/compiler/diagnosticMessages.json

c472ba5 Accept new baselines

Co-authored-by: Anders Hejlsberg <andersh@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
5 participants