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

During inference discriminate the target type before falling back to close-matching types #43853

Closed

Conversation

weswigham
Copy link
Member

Fixes #43753

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Apr 27, 2021
@weswigham
Copy link
Member Author

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 27, 2021

Heya @weswigham, I've started to run the tarball bundle task on this PR at d7ef49d. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 27, 2021

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 27, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 27, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 27, 2021

Heya @weswigham, I've started to run the parallelized community code test suite on this PR at d7ef49d. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 27, 2021

Hey @weswigham, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/101890/artifacts?artifactName=tgz&fileId=991B8D4D58C562C63FD753D178FF675DB3FE1F85A55B3C3B719C464510A7D96402&fileName=/typescript-4.3.0-insiders.20210427.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..43853

Metric master 43853 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 344,970k (± 0.03%) 345,022k (± 0.02%) +53k (+ 0.02%) 344,763k 345,143k
Parse Time 1.94s (± 0.39%) 1.91s (± 0.56%) -0.02s (- 1.29%) 1.89s 1.94s
Bind Time 0.84s (± 0.62%) 0.83s (± 0.44%) -0.00s (- 0.48%) 0.83s 0.84s
Check Time 5.26s (± 0.65%) 5.23s (± 0.46%) -0.03s (- 0.53%) 5.18s 5.30s
Emit Time 5.96s (± 0.66%) 5.95s (± 0.78%) -0.01s (- 0.10%) 5.85s 6.05s
Total Time 13.99s (± 0.39%) 13.93s (± 0.41%) -0.06s (- 0.44%) 13.79s 14.04s
Compiler-Unions - node (v10.16.3, x64)
Memory used 200,751k (± 0.02%) 205,922k (± 0.03%) +5,171k (+ 2.58%) 205,782k 206,080k
Parse Time 0.79s (± 0.76%) 0.78s (± 0.95%) -0.00s (- 0.25%) 0.77s 0.80s
Bind Time 0.53s (± 1.09%) 0.52s (± 0.94%) -0.01s (- 1.13%) 0.51s 0.53s
Check Time 7.55s (± 0.34%) 8.61s (± 0.79%) +1.06s (+14.01%) 8.49s 8.78s
Emit Time 2.53s (± 0.99%) 2.49s (± 1.54%) -0.04s (- 1.58%) 2.42s 2.59s
Total Time 11.40s (± 0.40%) 12.41s (± 0.65%) +1.01s (+ 8.86%) 12.25s 12.59s
Monaco - node (v10.16.3, x64)
Memory used 341,792k (± 0.01%) 341,826k (± 0.01%) +35k (+ 0.01%) 341,711k 341,908k
Parse Time 1.57s (± 0.80%) 1.56s (± 0.62%) -0.01s (- 0.64%) 1.53s 1.58s
Bind Time 0.74s (± 0.49%) 0.74s (± 0.40%) -0.00s (- 0.27%) 0.74s 0.75s
Check Time 5.35s (± 0.36%) 5.31s (± 0.44%) -0.03s (- 0.62%) 5.27s 5.37s
Emit Time 3.04s (± 0.83%) 3.01s (± 1.09%) -0.03s (- 0.92%) 2.92s 3.08s
Total Time 10.70s (± 0.40%) 10.63s (± 0.42%) -0.07s (- 0.68%) 10.51s 10.70s
TFS - node (v10.16.3, x64)
Memory used 304,260k (± 0.02%) 304,242k (± 0.04%) -18k (- 0.01%) 304,107k 304,642k
Parse Time 1.22s (± 0.51%) 1.21s (± 0.73%) -0.01s (- 0.49%) 1.20s 1.23s
Bind Time 0.71s (± 0.91%) 0.71s (± 0.63%) 0.00s ( 0.00%) 0.70s 0.72s
Check Time 4.80s (± 0.38%) 4.77s (± 0.51%) -0.03s (- 0.69%) 4.70s 4.83s
Emit Time 3.16s (± 1.42%) 3.18s (± 1.71%) +0.02s (+ 0.60%) 3.06s 3.32s
Total Time 9.89s (± 0.44%) 9.87s (± 0.63%) -0.02s (- 0.20%) 9.74s 10.05s
material-ui - node (v10.16.3, x64)
Memory used 473,789k (± 0.01%) 474,760k (± 0.01%) +971k (+ 0.20%) 474,669k 474,978k
Parse Time 1.95s (± 0.77%) 1.94s (± 0.51%) -0.01s (- 0.31%) 1.93s 1.98s
Bind Time 0.65s (± 0.75%) 0.65s (± 0.80%) -0.01s (- 0.76%) 0.64s 0.66s
Check Time 14.75s (± 0.80%) 22.38s (± 0.92%) 🔻+7.64s (+51.80%) 22.01s 22.88s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 17.35s (± 0.73%) 24.98s (± 0.85%) 🔻+7.63s (+43.96%) 24.59s 25.51s
Angular - node (v12.1.0, x64)
Memory used 322,587k (± 0.01%) 322,640k (± 0.03%) +52k (+ 0.02%) 322,406k 322,801k
Parse Time 1.92s (± 0.71%) 1.90s (± 0.48%) -0.02s (- 0.99%) 1.88s 1.92s
Bind Time 0.82s (± 0.60%) 0.82s (± 1.07%) -0.00s (- 0.61%) 0.81s 0.84s
Check Time 5.12s (± 0.46%) 5.09s (± 0.28%) -0.03s (- 0.57%) 5.07s 5.14s
Emit Time 6.13s (± 0.64%) 6.15s (± 1.05%) +0.02s (+ 0.31%) 6.09s 6.39s
Total Time 14.00s (± 0.29%) 13.97s (± 0.44%) -0.03s (- 0.21%) 13.90s 14.18s
Compiler-Unions - node (v12.1.0, x64)
Memory used 188,332k (± 0.35%) 191,901k (± 0.18%) +3,570k (+ 1.90%) 191,099k 192,288k
Parse Time 0.77s (± 0.47%) 0.76s (± 0.62%) -0.01s (- 1.42%) 0.75s 0.77s
Bind Time 0.53s (± 0.63%) 0.53s (± 0.98%) -0.00s (- 0.19%) 0.52s 0.54s
Check Time 7.05s (± 0.59%) 7.88s (± 0.77%) +0.84s (+11.88%) 7.78s 8.03s
Emit Time 2.49s (± 1.00%) 2.50s (± 1.11%) +0.01s (+ 0.44%) 2.42s 2.54s
Total Time 10.84s (± 0.49%) 11.68s (± 0.51%) +0.84s (+ 7.71%) 11.56s 11.80s
Monaco - node (v12.1.0, x64)
Memory used 324,186k (± 0.02%) 324,188k (± 0.03%) +2k (+ 0.00%) 323,932k 324,318k
Parse Time 1.55s (± 0.42%) 1.54s (± 0.42%) -0.01s (- 0.90%) 1.53s 1.55s
Bind Time 0.73s (± 1.00%) 0.72s (± 0.62%) -0.01s (- 1.37%) 0.71s 0.73s
Check Time 5.18s (± 0.45%) 5.17s (± 0.37%) -0.02s (- 0.29%) 5.13s 5.21s
Emit Time 3.08s (± 0.64%) 3.07s (± 0.49%) -0.01s (- 0.26%) 3.04s 3.10s
Total Time 10.54s (± 0.33%) 10.50s (± 0.25%) -0.04s (- 0.43%) 10.45s 10.55s
TFS - node (v12.1.0, x64)
Memory used 288,710k (± 0.02%) 288,753k (± 0.02%) +43k (+ 0.01%) 288,600k 288,908k
Parse Time 1.22s (± 0.74%) 1.22s (± 0.43%) -0.00s (- 0.00%) 1.21s 1.23s
Bind Time 0.69s (± 0.72%) 0.69s (± 0.65%) -0.01s (- 1.01%) 0.68s 0.70s
Check Time 4.70s (± 0.54%) 4.69s (± 0.71%) -0.02s (- 0.34%) 4.61s 4.78s
Emit Time 3.20s (± 0.70%) 3.19s (± 1.08%) -0.01s (- 0.41%) 3.13s 3.26s
Total Time 9.81s (± 0.43%) 9.78s (± 0.59%) -0.03s (- 0.34%) 9.65s 9.90s
material-ui - node (v12.1.0, x64)
Memory used 451,726k (± 0.01%) 451,919k (± 0.04%) +192k (+ 0.04%) 451,214k 452,070k
Parse Time 1.97s (± 0.66%) 1.95s (± 0.39%) -0.02s (- 1.27%) 1.93s 1.96s
Bind Time 0.64s (± 0.81%) 0.64s (± 0.77%) -0.01s (- 0.78%) 0.62s 0.64s
Check Time 13.25s (± 0.95%) 19.21s (± 0.54%) 🔻+5.96s (+44.98%) 18.98s 19.44s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.87s (± 0.82%) 21.80s (± 0.48%) 🔻+5.93s (+37.36%) 21.57s 22.03s
Angular - node (v14.15.1, x64)
Memory used 321,286k (± 0.01%) 321,378k (± 0.01%) +91k (+ 0.03%) 321,330k 321,411k
Parse Time 1.91s (± 0.40%) 1.91s (± 0.58%) -0.01s (- 0.42%) 1.89s 1.93s
Bind Time 0.87s (± 0.60%) 0.86s (± 0.43%) -0.00s (- 0.46%) 0.86s 0.87s
Check Time 5.13s (± 0.29%) 5.13s (± 0.50%) -0.00s (- 0.08%) 5.07s 5.17s
Emit Time 6.30s (± 0.79%) 6.25s (± 0.56%) -0.06s (- 0.90%) 6.17s 6.36s
Total Time 14.22s (± 0.38%) 14.14s (± 0.35%) -0.07s (- 0.52%) 14.07s 14.29s
Compiler-Unions - node (v14.15.1, x64)
Memory used 188,170k (± 0.61%) 192,422k (± 0.61%) +4,252k (+ 2.26%) 190,798k 194,032k
Parse Time 0.81s (± 0.46%) 0.80s (± 0.59%) -0.00s (- 0.25%) 0.79s 0.81s
Bind Time 0.56s (± 0.89%) 0.56s (± 0.67%) -0.00s (- 0.18%) 0.55s 0.56s
Check Time 7.17s (± 0.68%) 7.97s (± 0.56%) +0.80s (+11.24%) 7.90s 8.09s
Emit Time 2.51s (± 1.10%) 2.54s (± 0.91%) +0.03s (+ 1.16%) 2.49s 2.59s
Total Time 11.03s (± 0.52%) 11.87s (± 0.43%) +0.84s (+ 7.58%) 11.79s 12.00s
Monaco - node (v14.15.1, x64)
Memory used 323,257k (± 0.01%) 323,270k (± 0.01%) +13k (+ 0.00%) 323,221k 323,304k
Parse Time 1.57s (± 0.95%) 1.57s (± 0.44%) -0.01s (- 0.57%) 1.55s 1.58s
Bind Time 0.75s (± 0.63%) 0.75s (± 1.09%) -0.00s (- 0.40%) 0.73s 0.77s
Check Time 5.15s (± 0.54%) 5.11s (± 0.43%) -0.04s (- 0.74%) 5.07s 5.16s
Emit Time 3.13s (± 0.60%) 3.13s (± 0.51%) -0.00s (- 0.10%) 3.10s 3.17s
Total Time 10.61s (± 0.30%) 10.55s (± 0.29%) -0.06s (- 0.53%) 10.48s 10.61s
TFS - node (v14.15.1, x64)
Memory used 287,676k (± 0.01%) 287,690k (± 0.01%) +14k (+ 0.00%) 287,658k 287,746k
Parse Time 1.28s (± 1.82%) 1.27s (± 1.76%) -0.01s (- 0.86%) 1.23s 1.34s
Bind Time 0.71s (± 0.51%) 0.72s (± 0.66%) +0.00s (+ 0.42%) 0.71s 0.73s
Check Time 4.72s (± 0.49%) 4.71s (± 0.56%) -0.00s (- 0.11%) 4.66s 4.77s
Emit Time 3.30s (± 0.80%) 3.30s (± 0.98%) -0.00s (- 0.06%) 3.23s 3.36s
Total Time 10.01s (± 0.58%) 10.00s (± 0.55%) -0.01s (- 0.14%) 9.88s 10.11s
material-ui - node (v14.15.1, x64)
Memory used 449,779k (± 0.06%) 450,472k (± 0.08%) +693k (+ 0.15%) 449,488k 450,831k
Parse Time 2.00s (± 0.63%) 1.99s (± 0.82%) -0.01s (- 0.55%) 1.95s 2.02s
Bind Time 0.70s (± 0.83%) 0.70s (± 0.74%) -0.00s (- 0.57%) 0.69s 0.71s
Check Time 13.53s (± 0.93%) 18.84s (± 0.67%) 🔻+5.31s (+39.22%) 18.52s 19.11s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.23s (± 0.78%) 21.53s (± 0.57%) 🔻+5.29s (+32.60%) 21.24s 21.78s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-206-generic
Architecturex64
Available Memory16 GB
Available Memory8 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)
Benchmark Name Iterations
Current 43853 10
Baseline master 10

Developer Information:

Download Benchmark

@typescript-bot
Copy link
Collaborator

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

@weswigham
Copy link
Member Author

looks at performance results OK. Definitely needs better perf before this is a viable route to fix the linked issue. Union discrimination is expensive.

@sandersn
Copy link
Member

I vote to close this since it sounds too slow to use as-is. Is that OK @weswigham ?

@weswigham
Copy link
Member Author

Yeah, you're not wrong; I just can't immediately think of another way to fix the original issue (at least not one that doesn't totally overhaul inference, anyway), so trying to make this performant sounds like the best avenue to pursue.

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
Archived in project
Development

Successfully merging this pull request may close these issues.

Some regression with union of classes in TS4.2
3 participants