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

Relate non-augmenting subtypes without resorting to structural comparison #43624

Merged

Conversation

weswigham
Copy link
Member

@weswigham weswigham commented Apr 9, 2021

Fixes #43422 (this improves the perf of the example given to better-than-4.1-or-3.6 performance on my machine)

Much like the inspiration for #43435, this PR is about introducing a fast path for comparing trivial subtypes of Array<T> with Array<T> itself, without resorting to a full, slow, structural comparison (which is especially useful in cases where the comparison succeeds, as it avoids an exhaustive traversal of the Array type structure). This is useful, since non-augmenting array subtypes turn out to be pretty commonly used in the wild for describing recursive type structures in versions of TS that predate recursive type alias support.

Then, that's been generalized to normalize any empty subtype to it's single base type, if applicable, sharing these savings to empty subtypes of Map and other types, should they be present.

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

@typescript-bot pack this
@typescript-bot perf test this

@amcasey once the tarball is done, do you have a local non-reduced repro to verify this on?

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 9, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 9, 2021

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

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/100654/artifacts?artifactName=tgz&fileId=81DB7D969E5E473A3049D7C1BF683223EF66CECFEB90845D47635BD950E25DD502&fileName=/typescript-4.3.0-insiders.20210409.tgz"
    }
}

and then running npm install.

@amcasey
Copy link
Member

amcasey commented Apr 9, 2021

@weswigham The actual repro is https://github.com/vanilla/vanilla. You might get to it before I do, since I'm still on DT and not yet done with meetings for today.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..43624

Metric master 43624 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 345,096k (± 0.02%) 345,090k (± 0.01%) -6k (- 0.00%) 344,991k 345,233k
Parse Time 1.93s (± 0.32%) 1.93s (± 0.66%) +0.00s (+ 0.05%) 1.91s 1.97s
Bind Time 0.83s (± 0.59%) 0.83s (± 0.36%) -0.00s (- 0.24%) 0.83s 0.84s
Check Time 5.19s (± 0.34%) 5.21s (± 0.56%) +0.02s (+ 0.48%) 5.16s 5.27s
Emit Time 5.89s (± 0.24%) 5.90s (± 0.26%) +0.01s (+ 0.08%) 5.86s 5.92s
Total Time 13.84s (± 0.22%) 13.87s (± 0.25%) +0.03s (+ 0.21%) 13.82s 13.94s
Compiler-Unions - node (v10.16.3, x64)
Memory used 203,450k (± 0.02%) 203,428k (± 0.06%) -22k (- 0.01%) 203,186k 203,755k
Parse Time 0.79s (± 0.46%) 0.78s (± 0.63%) -0.00s (- 0.25%) 0.77s 0.79s
Bind Time 0.52s (± 1.35%) 0.52s (± 1.30%) +0.01s (+ 0.96%) 0.50s 0.53s
Check Time 7.48s (± 0.54%) 7.52s (± 0.54%) +0.04s (+ 0.57%) 7.42s 7.63s
Emit Time 2.58s (± 1.60%) 2.59s (± 0.84%) +0.01s (+ 0.50%) 2.53s 2.65s
Total Time 11.36s (± 0.72%) 11.43s (± 0.42%) +0.06s (+ 0.56%) 11.36s 11.56s
Monaco - node (v10.16.3, x64)
Memory used 342,748k (± 0.01%) 342,793k (± 0.02%) +45k (+ 0.01%) 342,672k 342,970k
Parse Time 1.55s (± 0.65%) 1.56s (± 1.00%) +0.01s (+ 0.39%) 1.52s 1.60s
Bind Time 0.74s (± 0.67%) 0.75s (± 0.66%) +0.01s (+ 1.36%) 0.73s 0.75s
Check Time 5.32s (± 0.54%) 5.38s (± 0.28%) +0.06s (+ 1.05%) 5.33s 5.41s
Emit Time 3.11s (± 0.57%) 3.14s (± 0.75%) +0.02s (+ 0.71%) 3.08s 3.18s
Total Time 10.73s (± 0.45%) 10.82s (± 0.38%) +0.09s (+ 0.86%) 10.69s 10.91s
TFS - node (v10.16.3, x64)
Memory used 304,372k (± 0.02%) 304,351k (± 0.02%) -21k (- 0.01%) 304,209k 304,464k
Parse Time 1.20s (± 0.41%) 1.21s (± 0.49%) +0.01s (+ 0.83%) 1.20s 1.23s
Bind Time 0.70s (± 0.84%) 0.70s (± 1.04%) -0.00s (- 0.28%) 0.69s 0.72s
Check Time 4.76s (± 0.47%) 4.80s (± 0.52%) +0.04s (+ 0.86%) 4.72s 4.85s
Emit Time 3.24s (± 1.13%) 3.24s (± 0.88%) -0.00s (- 0.06%) 3.17s 3.29s
Total Time 9.91s (± 0.43%) 9.96s (± 0.44%) +0.05s (+ 0.49%) 9.85s 10.04s
material-ui - node (v10.16.3, x64)
Memory used 466,017k (± 0.01%) 465,799k (± 0.02%) -218k (- 0.05%) 465,660k 465,992k
Parse Time 2.00s (± 0.45%) 2.00s (± 0.50%) +0.00s (+ 0.20%) 1.98s 2.02s
Bind Time 0.66s (± 1.28%) 0.67s (± 1.00%) +0.01s (+ 1.21%) 0.65s 0.68s
Check Time 14.28s (± 0.29%) 14.36s (± 0.71%) +0.08s (+ 0.57%) 14.24s 14.72s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.93s (± 0.26%) 17.03s (± 0.63%) +0.10s (+ 0.58%) 16.90s 17.40s
Angular - node (v12.1.0, x64)
Memory used 322,772k (± 0.01%) 322,774k (± 0.03%) +2k (+ 0.00%) 322,592k 323,012k
Parse Time 1.93s (± 0.46%) 1.93s (± 0.64%) +0.01s (+ 0.42%) 1.91s 1.97s
Bind Time 0.82s (± 0.73%) 0.82s (± 1.10%) +0.00s (+ 0.61%) 0.80s 0.84s
Check Time 5.08s (± 0.20%) 5.12s (± 0.50%) +0.04s (+ 0.75%) 5.06s 5.17s
Emit Time 5.98s (± 0.66%) 6.02s (± 0.41%) +0.04s (+ 0.59%) 5.94s 6.06s
Total Time 13.80s (± 0.27%) 13.89s (± 0.35%) +0.09s (+ 0.64%) 13.77s 14.02s
Compiler-Unions - node (v12.1.0, x64)
Memory used 190,194k (± 0.15%) 190,499k (± 0.15%) +305k (+ 0.16%) 189,842k 191,040k
Parse Time 0.77s (± 0.67%) 0.77s (± 0.86%) +0.00s (+ 0.26%) 0.76s 0.79s
Bind Time 0.53s (± 1.14%) 0.53s (± 0.94%) +0.00s (+ 0.19%) 0.52s 0.54s
Check Time 6.99s (± 0.51%) 7.09s (± 0.88%) +0.10s (+ 1.50%) 7.00s 7.30s
Emit Time 2.53s (± 1.08%) 2.55s (± 1.09%) +0.01s (+ 0.47%) 2.49s 2.63s
Total Time 10.82s (± 0.41%) 10.94s (± 0.66%) +0.12s (+ 1.10%) 10.78s 11.15s
Monaco - node (v12.1.0, x64)
Memory used 325,134k (± 0.01%) 325,097k (± 0.07%) -37k (- 0.01%) 324,271k 325,601k
Parse Time 1.54s (± 0.61%) 1.53s (± 0.64%) -0.01s (- 0.59%) 1.51s 1.55s
Bind Time 0.72s (± 0.31%) 0.72s (± 0.56%) 0.00s ( 0.00%) 0.71s 0.73s
Check Time 5.13s (± 0.21%) 5.19s (± 0.56%) +0.06s (+ 1.19%) 5.12s 5.24s
Emit Time 3.08s (± 0.27%) 3.11s (± 0.62%) +0.03s (+ 0.91%) 3.08s 3.18s
Total Time 10.46s (± 0.20%) 10.55s (± 0.33%) +0.08s (+ 0.78%) 10.43s 10.61s
TFS - node (v12.1.0, x64)
Memory used 288,812k (± 0.01%) 288,774k (± 0.02%) -38k (- 0.01%) 288,643k 288,864k
Parse Time 1.21s (± 0.61%) 1.21s (± 0.55%) +0.00s (+ 0.25%) 1.20s 1.23s
Bind Time 0.69s (± 1.01%) 0.69s (± 0.96%) -0.00s (- 0.14%) 0.68s 0.71s
Check Time 4.69s (± 0.43%) 4.73s (± 0.47%) +0.04s (+ 0.87%) 4.68s 4.77s
Emit Time 3.16s (± 0.65%) 3.17s (± 0.94%) +0.01s (+ 0.35%) 3.08s 3.24s
Total Time 9.75s (± 0.24%) 9.80s (± 0.33%) +0.05s (+ 0.55%) 9.71s 9.86s
material-ui - node (v12.1.0, x64)
Memory used 444,189k (± 0.01%) 443,909k (± 0.02%) -280k (- 0.06%) 443,662k 444,060k
Parse Time 2.01s (± 0.38%) 2.04s (± 0.57%) +0.02s (+ 1.09%) 2.02s 2.07s
Bind Time 0.63s (± 0.78%) 0.64s (± 0.77%) +0.00s (+ 0.16%) 0.63s 0.65s
Check Time 12.91s (± 0.61%) 12.99s (± 0.89%) +0.08s (+ 0.60%) 12.85s 13.40s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.56s (± 0.51%) 15.66s (± 0.71%) +0.10s (+ 0.65%) 15.49s 16.05s
Angular - node (v14.15.1, x64)
Memory used 321,431k (± 0.01%) 321,451k (± 0.01%) +20k (+ 0.01%) 321,376k 321,514k
Parse Time 1.92s (± 0.55%) 1.94s (± 0.60%) +0.02s (+ 0.99%) 1.91s 1.96s
Bind Time 0.86s (± 0.46%) 0.87s (± 0.55%) +0.01s (+ 0.70%) 0.86s 0.88s
Check Time 5.13s (± 0.45%) 5.15s (± 0.57%) +0.03s (+ 0.55%) 5.10s 5.22s
Emit Time 6.32s (± 0.58%) 6.36s (± 0.74%) +0.04s (+ 0.65%) 6.24s 6.46s
Total Time 14.23s (± 0.30%) 14.32s (± 0.53%) +0.09s (+ 0.66%) 14.14s 14.47s
Compiler-Unions - node (v14.15.1, x64)
Memory used 189,497k (± 0.01%) 189,396k (± 0.13%) -101k (- 0.05%) 188,415k 189,576k
Parse Time 0.81s (± 1.11%) 0.80s (± 0.87%) -0.00s (- 0.50%) 0.79s 0.82s
Bind Time 0.55s (± 0.54%) 0.56s (± 0.89%) +0.00s (+ 0.72%) 0.55s 0.57s
Check Time 7.09s (± 0.69%) 7.20s (± 0.86%) +0.11s (+ 1.49%) 7.08s 7.33s
Emit Time 2.54s (± 0.70%) 2.55s (± 1.03%) +0.01s (+ 0.24%) 2.52s 2.64s
Total Time 11.00s (± 0.45%) 11.11s (± 0.60%) +0.11s (+ 1.02%) 10.96s 11.24s
Monaco - node (v14.15.1, x64)
Memory used 324,133k (± 0.01%) 324,170k (± 0.01%) +37k (+ 0.01%) 324,111k 324,224k
Parse Time 1.56s (± 0.39%) 1.57s (± 0.38%) +0.01s (+ 0.64%) 1.55s 1.58s
Bind Time 0.74s (± 0.40%) 0.75s (± 0.87%) +0.01s (+ 0.81%) 0.74s 0.77s
Check Time 5.11s (± 0.48%) 5.17s (± 0.49%) +0.06s (+ 1.10%) 5.10s 5.23s
Emit Time 3.18s (± 0.78%) 3.20s (± 0.47%) +0.02s (+ 0.76%) 3.15s 3.23s
Total Time 10.59s (± 0.35%) 10.68s (± 0.30%) +0.09s (+ 0.87%) 10.60s 10.73s
TFS - node (v14.15.1, x64)
Memory used 287,746k (± 0.01%) 287,770k (± 0.01%) +25k (+ 0.01%) 287,700k 287,816k
Parse Time 1.26s (± 1.05%) 1.26s (± 1.08%) +0.00s (+ 0.16%) 1.24s 1.30s
Bind Time 0.72s (± 0.80%) 0.71s (± 0.81%) -0.01s (- 0.97%) 0.70s 0.73s
Check Time 4.71s (± 0.43%) 4.72s (± 0.59%) +0.01s (+ 0.25%) 4.66s 4.77s
Emit Time 3.24s (± 0.55%) 3.27s (± 0.80%) +0.03s (+ 0.89%) 3.23s 3.33s
Total Time 9.93s (± 0.21%) 9.96s (± 0.43%) +0.03s (+ 0.32%) 9.88s 10.08s
material-ui - node (v14.15.1, x64)
Memory used 442,316k (± 0.06%) 441,912k (± 0.08%) -403k (- 0.09%) 440,914k 442,190k
Parse Time 2.09s (± 0.49%) 2.10s (± 0.64%) +0.01s (+ 0.57%) 2.07s 2.13s
Bind Time 0.69s (± 0.75%) 0.69s (± 1.05%) +0.00s (+ 0.44%) 0.68s 0.71s
Check Time 13.02s (± 0.57%) 13.16s (± 0.68%) +0.14s (+ 1.05%) 13.01s 13.47s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.80s (± 0.49%) 15.95s (± 0.59%) +0.15s (+ 0.94%) 15.78s 16.26s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-206-generic
Architecturex64
Available Memory16 GB
Available Memory9 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 43624 10
Baseline master 10

Developer Information:

Download Benchmark

@microsoft microsoft deleted a comment from typescript-bot Apr 9, 2021
@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..43624

Metric master 43624 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 345,096k (± 0.02%) 345,070k (± 0.02%) -27k (- 0.01%) 344,906k 345,195k
Parse Time 1.93s (± 0.32%) 1.93s (± 0.63%) -0.00s (- 0.00%) 1.91s 1.96s
Bind Time 0.83s (± 0.59%) 0.83s (± 0.40%) -0.00s (- 0.48%) 0.82s 0.84s
Check Time 5.19s (± 0.34%) 5.22s (± 0.41%) +0.03s (+ 0.58%) 5.16s 5.27s
Emit Time 5.89s (± 0.24%) 5.94s (± 0.61%) +0.05s (+ 0.81%) 5.87s 6.02s
Total Time 13.84s (± 0.22%) 13.92s (± 0.34%) +0.07s (+ 0.53%) 13.82s 14.03s
Compiler-Unions - node (v10.16.3, x64)
Memory used 203,450k (± 0.02%) 203,388k (± 0.03%) -62k (- 0.03%) 203,269k 203,585k
Parse Time 0.79s (± 0.46%) 0.79s (± 0.87%) -0.00s (- 0.13%) 0.77s 0.80s
Bind Time 0.52s (± 1.35%) 0.52s (± 1.06%) +0.00s (+ 0.58%) 0.51s 0.53s
Check Time 7.48s (± 0.54%) 7.50s (± 0.42%) +0.02s (+ 0.29%) 7.46s 7.57s
Emit Time 2.58s (± 1.60%) 2.58s (± 0.80%) 0.00s ( 0.00%) 2.54s 2.62s
Total Time 11.36s (± 0.72%) 11.39s (± 0.33%) +0.03s (+ 0.23%) 11.31s 11.47s
Monaco - node (v10.16.3, x64)
Memory used 342,748k (± 0.01%) 342,752k (± 0.02%) +5k (+ 0.00%) 342,524k 342,903k
Parse Time 1.55s (± 0.65%) 1.56s (± 0.76%) +0.01s (+ 0.51%) 1.52s 1.58s
Bind Time 0.74s (± 0.67%) 0.74s (± 0.60%) +0.01s (+ 0.82%) 0.73s 0.75s
Check Time 5.32s (± 0.54%) 5.34s (± 0.45%) +0.02s (+ 0.36%) 5.28s 5.38s
Emit Time 3.11s (± 0.57%) 3.11s (± 0.47%) -0.00s (- 0.03%) 3.08s 3.15s
Total Time 10.73s (± 0.45%) 10.75s (± 0.29%) +0.03s (+ 0.25%) 10.69s 10.82s
TFS - node (v10.16.3, x64)
Memory used 304,372k (± 0.02%) 304,367k (± 0.02%) -5k (- 0.00%) 304,217k 304,516k
Parse Time 1.20s (± 0.41%) 1.21s (± 0.68%) +0.00s (+ 0.25%) 1.19s 1.23s
Bind Time 0.70s (± 0.84%) 0.70s (± 0.74%) -0.00s (- 0.43%) 0.69s 0.71s
Check Time 4.76s (± 0.47%) 4.77s (± 0.51%) +0.01s (+ 0.32%) 4.73s 4.85s
Emit Time 3.24s (± 1.13%) 3.22s (± 1.29%) -0.02s (- 0.71%) 3.12s 3.30s
Total Time 9.91s (± 0.43%) 9.90s (± 0.44%) -0.01s (- 0.08%) 9.83s 10.01s
material-ui - node (v10.16.3, x64)
Memory used 466,017k (± 0.01%) 465,822k (± 0.02%) -195k (- 0.04%) 465,662k 465,975k
Parse Time 2.00s (± 0.45%) 2.00s (± 0.33%) +0.00s (+ 0.20%) 1.99s 2.02s
Bind Time 0.66s (± 1.28%) 0.66s (± 1.31%) +0.00s (+ 0.46%) 0.64s 0.68s
Check Time 14.28s (± 0.29%) 14.28s (± 0.34%) +0.01s (+ 0.06%) 14.20s 14.42s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.93s (± 0.26%) 16.95s (± 0.30%) +0.02s (+ 0.11%) 16.85s 17.08s
Angular - node (v12.1.0, x64)
Memory used 322,772k (± 0.01%) 322,840k (± 0.03%) +68k (+ 0.02%) 322,570k 323,102k
Parse Time 1.93s (± 0.46%) 1.93s (± 0.87%) +0.00s (+ 0.05%) 1.89s 1.96s
Bind Time 0.82s (± 0.73%) 0.81s (± 0.42%) -0.00s (- 0.37%) 0.81s 0.82s
Check Time 5.08s (± 0.20%) 5.13s (± 0.42%) +0.05s (+ 0.89%) 5.07s 5.17s
Emit Time 5.98s (± 0.66%) 5.97s (± 0.69%) -0.01s (- 0.13%) 5.91s 6.10s
Total Time 13.80s (± 0.27%) 13.84s (± 0.40%) +0.04s (+ 0.27%) 13.76s 14.00s
Compiler-Unions - node (v12.1.0, x64)
Memory used 190,194k (± 0.15%) 190,548k (± 0.15%) +353k (+ 0.19%) 189,998k 191,020k
Parse Time 0.77s (± 0.67%) 0.77s (± 0.87%) -0.00s (- 0.52%) 0.75s 0.78s
Bind Time 0.53s (± 1.14%) 0.52s (± 1.06%) -0.00s (- 0.57%) 0.51s 0.53s
Check Time 6.99s (± 0.51%) 7.01s (± 0.53%) +0.03s (+ 0.39%) 6.94s 7.10s
Emit Time 2.53s (± 1.08%) 2.56s (± 1.66%) +0.02s (+ 0.95%) 2.47s 2.67s
Total Time 10.82s (± 0.41%) 10.86s (± 0.58%) +0.04s (+ 0.41%) 10.77s 11.05s
Monaco - node (v12.1.0, x64)
Memory used 325,134k (± 0.01%) 325,188k (± 0.02%) +54k (+ 0.02%) 325,093k 325,304k
Parse Time 1.54s (± 0.61%) 1.53s (± 0.66%) -0.00s (- 0.20%) 1.51s 1.55s
Bind Time 0.72s (± 0.31%) 0.72s (± 0.65%) +0.00s (+ 0.14%) 0.71s 0.73s
Check Time 5.13s (± 0.21%) 5.17s (± 0.47%) +0.04s (+ 0.70%) 5.12s 5.22s
Emit Time 3.08s (± 0.27%) 3.08s (± 0.38%) -0.00s (- 0.10%) 3.04s 3.10s
Total Time 10.46s (± 0.20%) 10.49s (± 0.25%) +0.03s (+ 0.29%) 10.42s 10.56s
TFS - node (v12.1.0, x64)
Memory used 288,812k (± 0.01%) 288,824k (± 0.01%) +13k (+ 0.00%) 288,765k 288,896k
Parse Time 1.21s (± 0.61%) 1.21s (± 0.56%) +0.00s (+ 0.33%) 1.20s 1.23s
Bind Time 0.69s (± 1.01%) 0.69s (± 0.81%) -0.00s (- 0.43%) 0.68s 0.70s
Check Time 4.69s (± 0.43%) 4.71s (± 0.49%) +0.03s (+ 0.58%) 4.68s 4.79s
Emit Time 3.16s (± 0.65%) 3.14s (± 0.47%) -0.02s (- 0.51%) 3.11s 3.18s
Total Time 9.75s (± 0.24%) 9.76s (± 0.36%) +0.01s (+ 0.11%) 9.71s 9.86s
material-ui - node (v12.1.0, x64)
Memory used 444,189k (± 0.01%) 443,789k (± 0.07%) -400k (- 0.09%) 442,616k 444,107k
Parse Time 2.01s (± 0.38%) 2.03s (± 0.69%) +0.02s (+ 0.79%) 2.00s 2.07s
Bind Time 0.63s (± 0.78%) 0.64s (± 0.73%) +0.01s (+ 0.79%) 0.63s 0.65s
Check Time 12.91s (± 0.61%) 12.90s (± 0.48%) -0.01s (- 0.04%) 12.81s 13.12s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.56s (± 0.51%) 15.58s (± 0.36%) +0.02s (+ 0.11%) 15.47s 15.76s
Angular - node (v14.15.1, x64)
Memory used 321,431k (± 0.01%) 321,451k (± 0.01%) +20k (+ 0.01%) 321,416k 321,525k
Parse Time 1.92s (± 0.55%) 1.92s (± 0.47%) -0.00s (- 0.21%) 1.90s 1.93s
Bind Time 0.86s (± 0.46%) 0.86s (± 0.88%) +0.00s (+ 0.46%) 0.85s 0.89s
Check Time 5.13s (± 0.45%) 5.13s (± 0.47%) +0.01s (+ 0.18%) 5.10s 5.19s
Emit Time 6.32s (± 0.58%) 6.32s (± 0.84%) +0.00s (+ 0.03%) 6.20s 6.48s
Total Time 14.23s (± 0.30%) 14.24s (± 0.44%) +0.01s (+ 0.06%) 14.08s 14.36s
Compiler-Unions - node (v14.15.1, x64)
Memory used 189,497k (± 0.01%) 189,520k (± 0.01%) +23k (+ 0.01%) 189,492k 189,560k
Parse Time 0.81s (± 1.11%) 0.80s (± 0.88%) -0.01s (- 0.75%) 0.79s 0.81s
Bind Time 0.55s (± 0.54%) 0.55s (± 0.40%) -0.00s (- 0.18%) 0.55s 0.56s
Check Time 7.09s (± 0.69%) 7.09s (± 0.38%) -0.01s (- 0.11%) 7.02s 7.16s
Emit Time 2.54s (± 0.70%) 2.55s (± 0.55%) +0.01s (+ 0.28%) 2.52s 2.58s
Total Time 11.00s (± 0.45%) 10.99s (± 0.28%) -0.01s (- 0.07%) 10.93s 11.05s
Monaco - node (v14.15.1, x64)
Memory used 324,133k (± 0.01%) 324,148k (± 0.01%) +15k (+ 0.00%) 324,079k 324,205k
Parse Time 1.56s (± 0.39%) 1.57s (± 0.48%) +0.01s (+ 0.71%) 1.54s 1.58s
Bind Time 0.74s (± 0.40%) 0.74s (± 0.40%) 0.00s ( 0.00%) 0.74s 0.75s
Check Time 5.11s (± 0.48%) 5.11s (± 0.47%) +0.01s (+ 0.12%) 5.07s 5.16s
Emit Time 3.18s (± 0.78%) 3.16s (± 0.54%) -0.02s (- 0.60%) 3.13s 3.21s
Total Time 10.59s (± 0.35%) 10.58s (± 0.29%) -0.01s (- 0.07%) 10.52s 10.68s
TFS - node (v14.15.1, x64)
Memory used 287,746k (± 0.01%) 287,773k (± 0.01%) +28k (+ 0.01%) 287,749k 287,803k
Parse Time 1.26s (± 1.05%) 1.27s (± 1.24%) +0.01s (+ 0.40%) 1.24s 1.31s
Bind Time 0.72s (± 0.80%) 0.71s (± 0.47%) -0.01s (- 1.39%) 0.70s 0.72s
Check Time 4.71s (± 0.43%) 4.71s (± 0.40%) +0.00s (+ 0.02%) 4.69s 4.77s
Emit Time 3.24s (± 0.55%) 3.25s (± 0.52%) +0.01s (+ 0.22%) 3.22s 3.29s
Total Time 9.93s (± 0.21%) 9.94s (± 0.44%) +0.01s (+ 0.06%) 9.88s 10.08s
material-ui - node (v14.15.1, x64)
Memory used 442,316k (± 0.06%) 442,134k (± 0.00%) -182k (- 0.04%) 442,100k 442,166k
Parse Time 2.09s (± 0.49%) 2.09s (± 0.55%) +0.00s (+ 0.19%) 2.07s 2.12s
Bind Time 0.69s (± 0.75%) 0.69s (± 0.72%) -0.00s (- 0.44%) 0.68s 0.70s
Check Time 13.02s (± 0.57%) 13.05s (± 0.46%) +0.03s (+ 0.23%) 12.93s 13.18s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.80s (± 0.49%) 15.83s (± 0.37%) +0.03s (+ 0.18%) 15.71s 15.96s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-206-generic
Architecturex64
Available Memory16 GB
Available Memory9 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 43624 10
Baseline master 10

Developer Information:

Download Benchmark

@andrewbranch
Copy link
Member

Why do the interfaces have to be non-augmenting? Checks on the interface declaration itself will ensure it’s assignable to its base type, so why can’t we just relate the type argument in the subtype interface’s extends clause to the target (Array) type parameter? E.g.

interface WhateverArray extends Array<string> {
  extraMember: unknown;
}

let x: (string | number)[] = undefined! as WhateverArray;

Wouldn’t it be sufficient here to check that string is assignable to string | number?

@weswigham
Copy link
Member Author

weswigham commented Apr 12, 2021

Teeeechnically non-conforming "subtypes" of array can exist in programs with errors, eg:

interface MyBadArray extends Array<string> {
    pop(): void;
}

declare var x: MyBadArray;
declare var y: Array<string>;

x = y;
y = x;

so relying on the subtype check might not be the best idea - especially if someone's @ts-ignore'd an error like this (especially since we may not know there's an error yet, since check order is arbitrary).

What I could do is expand this to non-array subtypes, eg

interface MyMap extends Map<string, string> {}

declare var x: MyMap;
declare var y: Map<string, string>;

x = y;
y = x;

and instead just check if the single base type of the type with no augmentations is or is an instantiation of the base type or target of the base type.

@amcasey
Copy link
Member

amcasey commented Apr 12, 2021

Timing for Vanilla is basically the same as #43623 (review) except that this gets things down to about 19s, rather than 22s.

I think both changes are good, even if they aren't both necessary to speed up Vanilla.

Edit: Stacking the two changes does not seem to provide additional benefits.

@@ -8,7 +8,7 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(17,5): error
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(33,5): error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'.
Target requires 3 element(s) but source may have fewer.
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'.
The types returned by 'pop()' are incompatible between these types.
Type '(string | number)[]' is not assignable to type 'Number[]'.
Copy link
Member

Choose a reason for hiding this comment

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

Seems better

@@ -18219,6 +18219,22 @@ namespace ts {
return result;
}

if (isNonAugmentingArraySubtype(source) && isArrayType(target)) {
Copy link
Member

Choose a reason for hiding this comment

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

What if they're both non-augmenting array subtypes?

Copy link
Member Author

Choose a reason for hiding this comment

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

We could relate them; it's just not as common in practice. This comes back to my "we could generalize this more" remark in my prior comment - this doesn't really need to be limited to just Arrays either.

Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

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

Looks sensible and seems to work in practice, but I don't know enough to vouch for the correctness.

@weswigham
Copy link
Member Author

@amcasey I assume this PR prevents the degenerate Maybe runaway whose perf is fixed in the other PR from ever occuring in the first place.

@amcasey
Copy link
Member

amcasey commented Apr 13, 2021

@weswigham Yes, that would be my guess as well, but I figured there might be other pseudo-aliases or other maybe-stack wins.

@ahejlsberg
Copy link
Member

I think it might be worthwhile generalizing this to all non-augmenting interface types with a single base type and also rolling it into getNormalizedType. It's not an uncommon pattern.

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Apr 13, 2021

@ahejlsberg @weswigham this was one of the sorts of things that @amcasey and I had brought up when we mentioned that type aliases were actually faster than extending interfaces.

You can imagine a general path that when an interface

  • has no call/construct/index signatures
  • has base types with no call/construct/index signatures
  • has properties that are mutually exclusive with those of their base types
  • has base types whose property names are mutually exclusive with each other's

then you simply copy the members over and set their assignability cache key.

But keeping it simple with just extending one type and introducing no members is a good start too.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 14, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 14, 2021

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 14, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 14, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 14, 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/100973/artifacts?artifactName=tgz&fileId=4FF14895F996DD6D204573DFA898324255B13C2698FC716A342F1F08E4ABF0AB02&fileName=/typescript-4.3.0-insiders.20210414.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/pr-build@4.3.0-pr-43624-23".;

@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.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..43624

Metric master 43624 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 345,095k (± 0.02%) 345,048k (± 0.02%) -47k (- 0.01%) 344,892k 345,244k
Parse Time 1.94s (± 0.60%) 1.93s (± 0.40%) -0.01s (- 0.52%) 1.91s 1.95s
Bind Time 0.83s (± 0.71%) 0.83s (± 0.63%) -0.01s (- 0.60%) 0.82s 0.84s
Check Time 5.18s (± 0.32%) 5.22s (± 0.48%) +0.04s (+ 0.83%) 5.16s 5.27s
Emit Time 5.92s (± 0.58%) 5.91s (± 0.49%) -0.01s (- 0.15%) 5.86s 5.98s
Total Time 13.88s (± 0.25%) 13.90s (± 0.38%) +0.02s (+ 0.12%) 13.81s 14.02s
Compiler-Unions - node (v10.16.3, x64)
Memory used 203,421k (± 0.04%) 203,407k (± 0.11%) -14k (- 0.01%) 202,561k 203,635k
Parse Time 0.78s (± 0.61%) 0.78s (± 0.74%) -0.00s (- 0.38%) 0.77s 0.79s
Bind Time 0.52s (± 1.28%) 0.53s (± 0.63%) +0.01s (+ 1.34%) 0.52s 0.54s
Check Time 7.47s (± 0.50%) 7.64s (± 0.43%) +0.16s (+ 2.17%) 7.52s 7.68s
Emit Time 2.57s (± 0.81%) 2.57s (± 0.75%) +0.01s (+ 0.27%) 2.53s 2.61s
Total Time 11.35s (± 0.44%) 11.52s (± 0.40%) +0.17s (+ 1.51%) 11.37s 11.60s
Monaco - node (v10.16.3, x64)
Memory used 342,808k (± 0.01%) 342,749k (± 0.02%) -59k (- 0.02%) 342,577k 342,930k
Parse Time 1.55s (± 0.66%) 1.55s (± 0.37%) -0.00s (- 0.06%) 1.54s 1.56s
Bind Time 0.74s (± 0.66%) 0.74s (± 0.45%) -0.00s (- 0.54%) 0.73s 0.75s
Check Time 5.32s (± 0.60%) 5.34s (± 0.35%) +0.01s (+ 0.26%) 5.29s 5.37s
Emit Time 3.12s (± 0.36%) 3.12s (± 0.44%) -0.01s (- 0.22%) 3.09s 3.15s
Total Time 10.74s (± 0.31%) 10.75s (± 0.21%) +0.00s (+ 0.02%) 10.70s 10.80s
TFS - node (v10.16.3, x64)
Memory used 304,387k (± 0.03%) 304,359k (± 0.02%) -28k (- 0.01%) 304,189k 304,511k
Parse Time 1.21s (± 0.61%) 1.20s (± 0.40%) -0.01s (- 0.58%) 1.19s 1.21s
Bind Time 0.70s (± 0.70%) 0.70s (± 0.68%) -0.00s (- 0.14%) 0.69s 0.71s
Check Time 4.77s (± 0.53%) 4.78s (± 0.58%) +0.01s (+ 0.13%) 4.74s 4.87s
Emit Time 3.26s (± 1.41%) 3.25s (± 1.16%) -0.01s (- 0.31%) 3.19s 3.36s
Total Time 9.94s (± 0.42%) 9.93s (± 0.55%) -0.01s (- 0.09%) 9.87s 10.07s
material-ui - node (v10.16.3, x64)
Memory used 466,091k (± 0.01%) 466,940k (± 0.01%) +848k (+ 0.18%) 466,844k 467,103k
Parse Time 2.01s (± 0.47%) 2.00s (± 0.53%) -0.00s (- 0.15%) 1.97s 2.02s
Bind Time 0.66s (± 1.43%) 0.65s (± 1.25%) -0.00s (- 0.61%) 0.64s 0.67s
Check Time 14.31s (± 0.54%) 14.41s (± 0.25%) +0.10s (+ 0.72%) 14.32s 14.46s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.97s (± 0.45%) 17.07s (± 0.21%) +0.10s (+ 0.57%) 16.98s 17.13s
Angular - node (v12.1.0, x64)
Memory used 322,806k (± 0.02%) 322,817k (± 0.03%) +10k (+ 0.00%) 322,606k 323,064k
Parse Time 1.92s (± 0.78%) 1.93s (± 0.67%) +0.01s (+ 0.31%) 1.90s 1.97s
Bind Time 0.81s (± 0.37%) 0.81s (± 0.45%) +0.00s (+ 0.25%) 0.81s 0.82s
Check Time 5.11s (± 0.55%) 5.15s (± 0.33%) +0.04s (+ 0.84%) 5.12s 5.18s
Emit Time 5.97s (± 0.35%) 5.99s (± 0.94%) +0.02s (+ 0.27%) 5.91s 6.20s
Total Time 13.81s (± 0.29%) 13.88s (± 0.47%) +0.06s (+ 0.47%) 13.80s 14.11s
Compiler-Unions - node (v12.1.0, x64)
Memory used 190,765k (± 0.43%) 190,426k (± 0.19%) -339k (- 0.18%) 189,468k 191,267k
Parse Time 0.77s (± 0.52%) 0.77s (± 0.95%) -0.00s (- 0.13%) 0.76s 0.79s
Bind Time 0.52s (± 0.69%) 0.53s (± 1.05%) +0.00s (+ 0.76%) 0.52s 0.54s
Check Time 7.00s (± 0.61%) 7.08s (± 0.27%) +0.08s (+ 1.13%) 7.04s 7.12s
Emit Time 2.54s (± 1.50%) 2.54s (± 0.71%) -0.00s (- 0.04%) 2.49s 2.58s
Total Time 10.83s (± 0.49%) 10.91s (± 0.17%) +0.08s (+ 0.74%) 10.87s 10.95s
Monaco - node (v12.1.0, x64)
Memory used 325,134k (± 0.02%) 325,140k (± 0.02%) +6k (+ 0.00%) 325,019k 325,376k
Parse Time 1.53s (± 0.32%) 1.53s (± 0.58%) +0.01s (+ 0.46%) 1.52s 1.55s
Bind Time 0.72s (± 0.86%) 0.72s (± 0.94%) +0.00s (+ 0.42%) 0.71s 0.74s
Check Time 5.12s (± 0.61%) 5.19s (± 0.59%) +0.07s (+ 1.35%) 5.15s 5.28s
Emit Time 3.07s (± 0.46%) 3.09s (± 0.87%) +0.02s (+ 0.65%) 3.05s 3.18s
Total Time 10.44s (± 0.38%) 10.54s (± 0.41%) +0.10s (+ 0.93%) 10.46s 10.63s
TFS - node (v12.1.0, x64)
Memory used 288,773k (± 0.01%) 288,849k (± 0.02%) +76k (+ 0.03%) 288,762k 288,999k
Parse Time 1.21s (± 1.02%) 1.20s (± 0.48%) -0.01s (- 0.41%) 1.19s 1.22s
Bind Time 0.69s (± 0.90%) 0.69s (± 0.96%) +0.00s (+ 0.58%) 0.68s 0.71s
Check Time 4.67s (± 0.38%) 4.71s (± 0.69%) +0.03s (+ 0.73%) 4.64s 4.82s
Emit Time 3.15s (± 0.93%) 3.16s (± 0.54%) +0.00s (+ 0.03%) 3.12s 3.19s
Total Time 9.72s (± 0.30%) 9.76s (± 0.41%) +0.04s (+ 0.37%) 9.65s 9.88s
material-ui - node (v12.1.0, x64)
Memory used 444,215k (± 0.02%) 444,995k (± 0.02%) +781k (+ 0.18%) 444,841k 445,211k
Parse Time 2.03s (± 0.57%) 2.03s (± 0.26%) -0.00s (- 0.10%) 2.02s 2.04s
Bind Time 0.64s (± 0.77%) 0.64s (± 0.87%) +0.00s (+ 0.31%) 0.63s 0.65s
Check Time 12.86s (± 0.32%) 12.99s (± 0.29%) +0.13s (+ 1.00%) 12.91s 13.05s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.53s (± 0.25%) 15.66s (± 0.24%) +0.13s (+ 0.82%) 15.59s 15.72s
Angular - node (v14.15.1, x64)
Memory used 321,423k (± 0.01%) 321,432k (± 0.01%) +9k (+ 0.00%) 321,378k 321,518k
Parse Time 1.93s (± 0.55%) 1.92s (± 0.34%) -0.01s (- 0.47%) 1.91s 1.94s
Bind Time 0.86s (± 0.46%) 0.86s (± 0.82%) -0.00s (- 0.23%) 0.85s 0.88s
Check Time 5.11s (± 0.32%) 5.16s (± 0.58%) +0.05s (+ 1.06%) 5.11s 5.24s
Emit Time 6.32s (± 0.38%) 6.26s (± 0.57%) -0.06s (- 0.96%) 6.20s 6.38s
Total Time 14.22s (± 0.17%) 14.20s (± 0.42%) -0.02s (- 0.12%) 14.10s 14.39s
Compiler-Unions - node (v14.15.1, x64)
Memory used 189,492k (± 0.01%) 189,552k (± 0.01%) +60k (+ 0.03%) 189,497k 189,626k
Parse Time 0.81s (± 0.46%) 0.80s (± 0.42%) -0.00s (- 0.25%) 0.80s 0.81s
Bind Time 0.55s (± 0.90%) 0.55s (± 0.62%) -0.00s (- 0.36%) 0.55s 0.56s
Check Time 7.12s (± 0.80%) 7.17s (± 0.53%) +0.05s (+ 0.69%) 7.08s 7.23s
Emit Time 2.54s (± 0.59%) 2.55s (± 0.61%) +0.01s (+ 0.31%) 2.52s 2.59s
Total Time 11.03s (± 0.61%) 11.08s (± 0.42%) +0.05s (+ 0.45%) 10.97s 11.17s
Monaco - node (v14.15.1, x64)
Memory used 324,177k (± 0.01%) 324,120k (± 0.01%) -58k (- 0.02%) 324,036k 324,159k
Parse Time 1.57s (± 0.53%) 1.56s (± 0.51%) -0.00s (- 0.19%) 1.54s 1.58s
Bind Time 0.74s (± 0.46%) 0.74s (± 0.60%) -0.00s (- 0.13%) 0.73s 0.75s
Check Time 5.12s (± 0.64%) 5.16s (± 0.39%) +0.04s (+ 0.80%) 5.11s 5.20s
Emit Time 3.18s (± 0.52%) 3.17s (± 0.77%) -0.01s (- 0.31%) 3.13s 3.26s
Total Time 10.61s (± 0.35%) 10.64s (± 0.40%) +0.03s (+ 0.25%) 10.57s 10.78s
TFS - node (v14.15.1, x64)
Memory used 287,779k (± 0.01%) 287,813k (± 0.01%) +35k (+ 0.01%) 287,774k 287,861k
Parse Time 1.26s (± 0.98%) 1.26s (± 1.75%) +0.00s (+ 0.16%) 1.23s 1.34s
Bind Time 0.72s (± 0.66%) 0.71s (± 0.56%) -0.01s (- 0.84%) 0.70s 0.72s
Check Time 4.71s (± 0.35%) 4.73s (± 0.50%) +0.03s (+ 0.55%) 4.71s 4.82s
Emit Time 3.26s (± 0.64%) 3.25s (± 0.44%) -0.01s (- 0.37%) 3.22s 3.29s
Total Time 9.94s (± 0.28%) 9.95s (± 0.31%) +0.01s (+ 0.11%) 9.89s 10.04s
material-ui - node (v14.15.1, x64)
Memory used 442,477k (± 0.00%) 443,112k (± 0.03%) +635k (+ 0.14%) 442,521k 443,214k
Parse Time 2.09s (± 0.74%) 2.09s (± 0.51%) +0.01s (+ 0.34%) 2.08s 2.12s
Bind Time 0.69s (± 0.69%) 0.70s (± 0.68%) +0.00s (+ 0.58%) 0.69s 0.71s
Check Time 13.03s (± 0.56%) 13.18s (± 0.83%) +0.15s (+ 1.14%) 13.05s 13.47s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.81s (± 0.47%) 15.97s (± 0.69%) +0.16s (+ 1.01%) 15.83s 16.28s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-206-generic
Architecturex64
Available Memory16 GB
Available Memory9 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 43624 10
Baseline master 10

Developer Information:

Download Benchmark

Copy link
Member

@ahejlsberg ahejlsberg left a comment

Choose a reason for hiding this comment

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

I really like this change, but let's see if we can get the perf cost down.

src/compiler/checker.ts Outdated Show resolved Hide resolved
@weswigham
Copy link
Member Author

@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 20, 2021

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..43624

Metric master 43624 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 343,874k (± 0.02%) 343,924k (± 0.03%) +50k (+ 0.01%) 343,708k 344,209k
Parse Time 1.95s (± 0.42%) 1.94s (± 0.65%) -0.01s (- 0.51%) 1.90s 1.97s
Bind Time 0.84s (± 1.15%) 0.84s (± 1.00%) +0.00s (+ 0.00%) 0.83s 0.86s
Check Time 5.22s (± 0.72%) 5.23s (± 0.31%) +0.01s (+ 0.21%) 5.19s 5.26s
Emit Time 5.88s (± 0.57%) 5.92s (± 0.68%) +0.04s (+ 0.61%) 5.81s 5.99s
Total Time 13.89s (± 0.44%) 13.93s (± 0.37%) +0.04s (+ 0.29%) 13.79s 14.02s
Compiler-Unions - node (v10.16.3, x64)
Memory used 200,593k (± 0.15%) 200,576k (± 0.16%) -17k (- 0.01%) 199,707k 200,944k
Parse Time 0.79s (± 0.76%) 0.78s (± 0.74%) -0.01s (- 0.76%) 0.77s 0.79s
Bind Time 0.53s (± 1.30%) 0.52s (± 1.11%) -0.00s (- 0.38%) 0.51s 0.53s
Check Time 7.55s (± 0.89%) 7.55s (± 0.56%) -0.01s (- 0.08%) 7.49s 7.70s
Emit Time 2.52s (± 1.32%) 2.51s (± 1.01%) -0.01s (- 0.28%) 2.47s 2.56s
Total Time 11.38s (± 0.75%) 11.36s (± 0.38%) -0.02s (- 0.19%) 11.28s 11.49s
Monaco - node (v10.16.3, x64)
Memory used 341,730k (± 0.03%) 341,680k (± 0.02%) -50k (- 0.01%) 341,560k 341,947k
Parse Time 1.56s (± 0.91%) 1.56s (± 0.68%) +0.00s (+ 0.19%) 1.53s 1.58s
Bind Time 0.74s (± 0.54%) 0.74s (± 0.70%) -0.00s (- 0.00%) 0.73s 0.75s
Check Time 5.32s (± 0.57%) 5.38s (± 0.40%) +0.06s (+ 1.07%) 5.32s 5.44s
Emit Time 3.01s (± 0.67%) 3.01s (± 0.50%) -0.00s (- 0.00%) 2.98s 3.04s
Total Time 10.63s (± 0.42%) 10.69s (± 0.36%) +0.06s (+ 0.58%) 10.57s 10.79s
TFS - node (v10.16.3, x64)
Memory used 304,098k (± 0.02%) 304,175k (± 0.02%) +76k (+ 0.03%) 304,068k 304,296k
Parse Time 1.22s (± 0.55%) 1.21s (± 0.41%) -0.00s (- 0.25%) 1.20s 1.22s
Bind Time 0.71s (± 0.91%) 0.70s (± 0.79%) -0.01s (- 0.85%) 0.69s 0.71s
Check Time 4.78s (± 0.51%) 4.80s (± 0.73%) +0.02s (+ 0.38%) 4.77s 4.93s
Emit Time 3.23s (± 1.66%) 3.20s (± 2.77%) -0.03s (- 0.90%) 3.03s 3.46s
Total Time 9.93s (± 0.53%) 9.92s (± 1.07%) -0.02s (- 0.18%) 9.74s 10.21s
material-ui - node (v10.16.3, x64)
Memory used 464,102k (± 0.01%) 464,857k (± 0.02%) +756k (+ 0.16%) 464,736k 465,099k
Parse Time 2.01s (± 0.47%) 2.01s (± 0.78%) 0.00s ( 0.00%) 1.98s 2.05s
Bind Time 0.66s (± 1.13%) 0.65s (± 1.12%) -0.01s (- 1.66%) 0.64s 0.67s
Check Time 14.48s (± 0.78%) 14.49s (± 0.58%) +0.01s (+ 0.09%) 14.35s 14.78s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 17.16s (± 0.68%) 17.16s (± 0.50%) +0.00s (+ 0.02%) 17.01s 17.45s
Angular - node (v12.1.0, x64)
Memory used 321,747k (± 0.02%) 321,706k (± 0.03%) -41k (- 0.01%) 321,511k 321,932k
Parse Time 1.93s (± 0.58%) 1.92s (± 0.79%) -0.00s (- 0.26%) 1.89s 1.96s
Bind Time 0.82s (± 0.82%) 0.82s (± 0.58%) 0.00s ( 0.00%) 0.81s 0.83s
Check Time 5.09s (± 0.39%) 5.12s (± 0.38%) +0.03s (+ 0.57%) 5.08s 5.17s
Emit Time 6.11s (± 0.41%) 6.11s (± 0.53%) +0.01s (+ 0.08%) 6.04s 6.17s
Total Time 13.94s (± 0.29%) 13.97s (± 0.33%) +0.03s (+ 0.19%) 13.87s 14.08s
Compiler-Unions - node (v12.1.0, x64)
Memory used 187,961k (± 0.15%) 187,871k (± 0.20%) -90k (- 0.05%) 186,730k 188,443k
Parse Time 0.77s (± 0.68%) 0.78s (± 0.61%) +0.01s (+ 1.04%) 0.77s 0.79s
Bind Time 0.53s (± 0.98%) 0.53s (± 0.71%) -0.00s (- 0.76%) 0.52s 0.53s
Check Time 6.98s (± 0.55%) 7.02s (± 0.68%) +0.04s (+ 0.57%) 6.94s 7.17s
Emit Time 2.50s (± 1.52%) 2.50s (± 0.76%) -0.00s (- 0.04%) 2.46s 2.54s
Total Time 10.77s (± 0.35%) 10.82s (± 0.52%) +0.05s (+ 0.42%) 10.72s 10.97s
Monaco - node (v12.1.0, x64)
Memory used 324,125k (± 0.03%) 323,984k (± 0.02%) -141k (- 0.04%) 323,873k 324,076k
Parse Time 1.55s (± 1.05%) 1.54s (± 0.68%) -0.01s (- 0.65%) 1.52s 1.56s
Bind Time 0.72s (± 0.46%) 0.72s (± 0.72%) -0.00s (- 0.14%) 0.71s 0.73s
Check Time 5.14s (± 0.56%) 5.17s (± 0.52%) +0.03s (+ 0.62%) 5.13s 5.26s
Emit Time 3.07s (± 0.72%) 3.07s (± 0.55%) +0.00s (+ 0.16%) 3.04s 3.12s
Total Time 10.47s (± 0.34%) 10.50s (± 0.29%) +0.02s (+ 0.23%) 10.45s 10.57s
TFS - node (v12.1.0, x64)
Memory used 288,657k (± 0.02%) 288,596k (± 0.02%) -61k (- 0.02%) 288,499k 288,731k
Parse Time 1.21s (± 0.58%) 1.21s (± 0.37%) -0.00s (- 0.25%) 1.20s 1.22s
Bind Time 0.69s (± 0.58%) 0.69s (± 0.97%) -0.00s (- 0.58%) 0.67s 0.70s
Check Time 4.68s (± 0.69%) 4.70s (± 0.49%) +0.02s (+ 0.45%) 4.66s 4.76s
Emit Time 3.21s (± 0.81%) 3.19s (± 1.29%) -0.02s (- 0.56%) 3.12s 3.29s
Total Time 9.80s (± 0.35%) 9.79s (± 0.39%) -0.01s (- 0.08%) 9.69s 9.87s
material-ui - node (v12.1.0, x64)
Memory used 442,285k (± 0.01%) 442,631k (± 0.10%) +346k (+ 0.08%) 441,820k 443,167k
Parse Time 2.03s (± 0.46%) 2.02s (± 0.24%) -0.01s (- 0.39%) 2.01s 2.03s
Bind Time 0.64s (± 0.94%) 0.65s (± 0.73%) +0.01s (+ 1.89%) 0.64s 0.66s
Check Time 12.96s (± 0.60%) 13.20s (± 1.08%) +0.24s (+ 1.88%) 12.94s 13.53s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.63s (± 0.52%) 15.88s (± 0.90%) +0.25s (+ 1.60%) 15.62s 16.20s
Angular - node (v14.15.1, x64)
Memory used 320,273k (± 0.00%) 320,330k (± 0.01%) +57k (+ 0.02%) 320,282k 320,413k
Parse Time 1.93s (± 0.36%) 1.93s (± 0.40%) 0.00s ( 0.00%) 1.91s 1.95s
Bind Time 0.87s (± 1.11%) 0.86s (± 0.39%) -0.01s (- 0.92%) 0.86s 0.87s
Check Time 5.12s (± 0.58%) 5.15s (± 0.44%) +0.03s (+ 0.68%) 5.12s 5.21s
Emit Time 6.28s (± 0.51%) 6.23s (± 0.82%) -0.05s (- 0.75%) 6.11s 6.38s
Total Time 14.19s (± 0.42%) 14.17s (± 0.50%) -0.02s (- 0.15%) 14.00s 14.37s
Compiler-Unions - node (v14.15.1, x64)
Memory used 189,067k (± 0.58%) 188,779k (± 0.62%) -288k (- 0.15%) 186,829k 190,120k
Parse Time 0.80s (± 0.28%) 0.80s (± 0.37%) +0.00s (+ 0.12%) 0.80s 0.81s
Bind Time 0.55s (± 0.67%) 0.56s (± 0.65%) +0.00s (+ 0.18%) 0.55s 0.56s
Check Time 7.08s (± 0.66%) 7.14s (± 0.58%) +0.06s (+ 0.83%) 7.05s 7.27s
Emit Time 2.48s (± 0.78%) 2.48s (± 0.54%) -0.00s (- 0.16%) 2.45s 2.51s
Total Time 10.92s (± 0.51%) 10.98s (± 0.36%) +0.06s (+ 0.52%) 10.87s 11.07s
Monaco - node (v14.15.1, x64)
Memory used 323,207k (± 0.01%) 323,119k (± 0.01%) -88k (- 0.03%) 323,071k 323,167k
Parse Time 1.57s (± 0.65%) 1.57s (± 0.80%) -0.00s (- 0.32%) 1.55s 1.60s
Bind Time 0.74s (± 0.80%) 0.75s (± 1.43%) +0.00s (+ 0.67%) 0.74s 0.79s
Check Time 5.12s (± 0.43%) 5.16s (± 0.41%) +0.04s (+ 0.70%) 5.08s 5.20s
Emit Time 3.12s (± 0.58%) 3.12s (± 0.50%) +0.00s (+ 0.16%) 3.09s 3.16s
Total Time 10.55s (± 0.37%) 10.60s (± 0.27%) +0.04s (+ 0.41%) 10.51s 10.67s
TFS - node (v14.15.1, x64)
Memory used 287,646k (± 0.01%) 287,628k (± 0.01%) -18k (- 0.01%) 287,592k 287,659k
Parse Time 1.27s (± 1.40%) 1.26s (± 0.96%) -0.01s (- 0.55%) 1.25s 1.30s
Bind Time 0.72s (± 0.62%) 0.72s (± 1.04%) -0.00s (- 0.14%) 0.70s 0.74s
Check Time 4.70s (± 0.46%) 4.71s (± 0.44%) +0.01s (+ 0.30%) 4.67s 4.76s
Emit Time 3.29s (± 0.51%) 3.28s (± 0.54%) -0.01s (- 0.36%) 3.25s 3.33s
Total Time 9.98s (± 0.30%) 9.98s (± 0.30%) -0.01s (- 0.06%) 9.91s 10.06s
material-ui - node (v14.15.1, x64)
Memory used 440,472k (± 0.00%) 441,070k (± 0.06%) +598k (+ 0.14%) 439,948k 441,240k
Parse Time 2.10s (± 0.64%) 2.09s (± 0.58%) -0.01s (- 0.48%) 2.06s 2.12s
Bind Time 0.70s (± 0.71%) 0.69s (± 0.52%) -0.00s (- 0.29%) 0.69s 0.70s
Check Time 13.27s (± 0.74%) 13.27s (± 0.79%) +0.01s (+ 0.04%) 13.10s 13.65s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.06s (± 0.66%) 16.06s (± 0.61%) -0.01s (- 0.05%) 15.88s 16.40s
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 43624 10
Baseline master 10

Developer Information:

Download Benchmark

@weswigham weswigham requested a review from ahejlsberg April 21, 2021 19:46
@weswigham
Copy link
Member Author

@ahejlsberg this now uses flags to indicate the presence of a cache value, as requested.

@weswigham
Copy link
Member Author

@ahejlsberg ping?

Copy link
Member

@ahejlsberg ahejlsberg left a comment

Choose a reason for hiding this comment

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

Approved with the minor change below.

src/compiler/types.ts Outdated Show resolved Hide resolved
@weswigham weswigham merged commit 7748694 into microsoft:master Apr 28, 2021
@xaviergonz
Copy link

xaviergonz commented May 28, 2021

@weswigham @ahejlsberg Just FYI: I think this PR seems to be related to this regression
#44281

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

Successfully merging this pull request may close these issues.

Perf regression: preserving union aliases
7 participants