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

Optimize checking involving large discriminated union types #42556

Merged
merged 18 commits into from Mar 1, 2021
Merged

Conversation

ahejlsberg
Copy link
Member

@ahejlsberg ahejlsberg commented Jan 30, 2021

This PR implements multiple optimizations:

  1. Use constituent maps when checking relations involving large discriminated union types on the target side.
  2. Use constituent maps when reducing large discriminated union types that appear as contextual types.
  3. Use constituent maps for in control flow analysis involving large discriminated union types.
  4. Perform deduplication of structurally equivalent object and array literal element types in array literals.
  5. Cache results of subtype reduction when constructing union types.
  6. Use discriminant property checks to quickly disqualify types from subtype checks during subtype reduction.

When feasible, constituent maps that map from discriminant unit types to corresponding constituent types are constructed for large union types. These maps allow matching constituents to be quickly identified through simple lookups instead of expensive linear scans. Constituent maps are deemed feasible for unions with 10 or more constituents and less than 25% duplication in discriminant keys. The maps are purely a fast path optimization--all existing logic remains in place with unchanged semantics for cases where the maps don't apply.

The optimizations reduce the check time of the worst case examples from #42522 close to 10x (from 1.6s to 0.18s). Furthermore, the check times for the Compiler-with-unions and Monaco test cases are reduced by 32% and 6% respectively.

Fixes #42522.

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

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 30, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 30, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 30, 2021

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 30, 2021

Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 216266b. 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 - master..42556

Metric master 42556 Delta Best Worst
Angular - node (v14.15.1, x64)
Memory used 322,724k (± 0.01%) 322,323k (± 0.07%) -400k (- 0.12%) 321,387k 322,462k
Parse Time 1.97s (± 0.39%) 1.98s (± 0.68%) +0.01s (+ 0.30%) 1.96s 2.02s
Bind Time 0.86s (± 0.55%) 0.87s (± 0.69%) +0.00s (+ 0.35%) 0.85s 0.88s
Check Time 4.90s (± 0.33%) 4.88s (± 0.58%) -0.02s (- 0.31%) 4.84s 4.97s
Emit Time 5.52s (± 0.36%) 5.58s (± 0.90%) +0.06s (+ 1.03%) 5.48s 5.73s
Total Time 13.25s (± 0.23%) 13.30s (± 0.61%) +0.05s (+ 0.37%) 13.17s 13.53s
Compiler-Unions - node (v14.15.1, x64)
Memory used 201,806k (± 0.55%) 201,850k (± 0.58%) +44k (+ 0.02%) 200,423k 204,258k
Parse Time 0.80s (± 0.74%) 0.80s (± 0.69%) -0.00s (- 0.25%) 0.79s 0.82s
Bind Time 0.53s (± 0.42%) 0.53s (± 0.75%) +0.00s (+ 0.38%) 0.52s 0.54s
Check Time 9.83s (± 0.58%) 10.01s (± 0.88%) +0.18s (+ 1.80%) 9.84s 10.28s
Emit Time 2.34s (± 0.75%) 2.33s (± 0.89%) -0.01s (- 0.26%) 2.30s 2.39s
Total Time 13.50s (± 0.43%) 13.67s (± 0.70%) +0.17s (+ 1.29%) 13.47s 13.97s
Monaco - node (v14.15.1, x64)
Memory used 336,829k (± 0.01%) 336,764k (± 0.01%) -64k (- 0.02%) 336,715k 336,822k
Parse Time 1.60s (± 0.51%) 1.61s (± 0.61%) +0.00s (+ 0.31%) 1.59s 1.63s
Bind Time 0.74s (± 0.68%) 0.74s (± 0.68%) 0.00s ( 0.00%) 0.73s 0.75s
Check Time 4.86s (± 0.39%) 4.80s (± 0.35%) -0.05s (- 1.11%) 4.78s 4.85s
Emit Time 2.92s (± 0.61%) 2.94s (± 0.62%) +0.02s (+ 0.72%) 2.90s 2.98s
Total Time 10.12s (± 0.23%) 10.09s (± 0.35%) -0.03s (- 0.29%) 10.03s 10.17s
TFS - node (v14.15.1, x64)
Memory used 291,597k (± 0.00%) 291,661k (± 0.00%) +65k (+ 0.02%) 291,641k 291,683k
Parse Time 1.27s (± 0.57%) 1.28s (± 1.70%) +0.01s (+ 0.63%) 1.25s 1.35s
Bind Time 0.70s (± 0.72%) 0.69s (± 0.84%) -0.00s (- 0.29%) 0.68s 0.71s
Check Time 4.50s (± 0.46%) 4.50s (± 0.40%) -0.00s (- 0.04%) 4.46s 4.54s
Emit Time 3.06s (± 0.46%) 3.07s (± 0.79%) +0.02s (+ 0.52%) 3.02s 3.13s
Total Time 9.53s (± 0.35%) 9.55s (± 0.20%) +0.02s (+ 0.22%) 9.51s 9.59s
material-ui - node (v14.15.1, x64)
Memory used 471,889k (± 0.06%) 484,159k (± 0.05%) +12,271k (+ 2.60%) 483,797k 484,534k
Parse Time 2.13s (± 0.47%) 2.13s (± 0.64%) -0.00s (- 0.00%) 2.11s 2.16s
Bind Time 0.70s (± 0.68%) 0.70s (± 1.35%) +0.00s (+ 0.14%) 0.69s 0.72s
Check Time 12.65s (± 0.71%) 12.93s (± 0.65%) +0.28s (+ 2.18%) 12.77s 13.07s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.48s (± 0.61%) 15.76s (± 0.53%) +0.28s (+ 1.82%) 15.57s 15.93s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-198-generic
Architecturex64
Available Memory16 GB
Available Memory8 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)
Benchmark Name Iterations
Current 42556 10
Baseline master 10

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

@ahejlsberg
Copy link
Member Author

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 31, 2021

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 31, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 31, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 31, 2021

Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 9e8f24b. 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 - master..42556

Metric master 42556 Delta Best Worst
Angular - node (v14.15.1, x64)
Memory used 322,724k (± 0.01%) 322,021k (± 0.01%) -703k (- 0.22%) 321,968k 322,082k
Parse Time 1.97s (± 0.39%) 1.97s (± 0.45%) -0.00s (- 0.10%) 1.95s 1.99s
Bind Time 0.86s (± 0.55%) 0.86s (± 0.55%) -0.00s (- 0.35%) 0.85s 0.87s
Check Time 4.90s (± 0.33%) 4.86s (± 0.32%) -0.04s (- 0.74%) 4.83s 4.89s
Emit Time 5.52s (± 0.36%) 5.56s (± 0.70%) +0.04s (+ 0.74%) 5.48s 5.66s
Total Time 13.25s (± 0.23%) 13.25s (± 0.42%) +0.00s (+ 0.01%) 13.16s 13.39s
Compiler-Unions - node (v14.15.1, x64)
Memory used 201,806k (± 0.55%) 200,274k (± 0.10%) -1,532k (- 0.76%) 199,716k 200,494k
Parse Time 0.80s (± 0.74%) 0.80s (± 0.59%) -0.00s (- 0.12%) 0.79s 0.81s
Bind Time 0.53s (± 0.42%) 0.53s (± 1.09%) +0.00s (+ 0.19%) 0.52s 0.54s
Check Time 9.83s (± 0.58%) 9.82s (± 0.83%) -0.01s (- 0.08%) 9.70s 10.11s
Emit Time 2.34s (± 0.75%) 2.35s (± 1.66%) +0.01s (+ 0.60%) 2.29s 2.47s
Total Time 13.50s (± 0.43%) 13.51s (± 0.82%) +0.01s (+ 0.07%) 13.34s 13.93s
Monaco - node (v14.15.1, x64)
Memory used 336,829k (± 0.01%) 336,743k (± 0.01%) -86k (- 0.03%) 336,701k 336,793k
Parse Time 1.60s (± 0.51%) 1.61s (± 0.62%) +0.01s (+ 0.62%) 1.59s 1.63s
Bind Time 0.74s (± 0.68%) 0.73s (± 0.46%) -0.00s (- 0.27%) 0.73s 0.74s
Check Time 4.86s (± 0.39%) 4.81s (± 0.60%) -0.05s (- 0.99%) 4.75s 4.90s
Emit Time 2.92s (± 0.61%) 2.92s (± 0.32%) -0.00s (- 0.07%) 2.90s 2.94s
Total Time 10.12s (± 0.23%) 10.08s (± 0.31%) -0.04s (- 0.40%) 10.03s 10.17s
TFS - node (v14.15.1, x64)
Memory used 291,597k (± 0.00%) 291,651k (± 0.00%) +55k (+ 0.02%) 291,615k 291,680k
Parse Time 1.27s (± 0.57%) 1.27s (± 0.49%) -0.00s (- 0.24%) 1.26s 1.28s
Bind Time 0.70s (± 0.72%) 0.69s (± 1.05%) -0.00s (- 0.43%) 0.68s 0.71s
Check Time 4.50s (± 0.46%) 4.50s (± 0.56%) -0.01s (- 0.16%) 4.43s 4.55s
Emit Time 3.06s (± 0.46%) 3.05s (± 0.54%) -0.00s (- 0.16%) 3.02s 3.09s
Total Time 9.53s (± 0.35%) 9.51s (± 0.33%) -0.02s (- 0.17%) 9.44s 9.59s
material-ui - node (v14.15.1, x64)
Memory used 471,889k (± 0.06%) 471,649k (± 0.06%) -239k (- 0.05%) 471,009k 472,282k
Parse Time 2.13s (± 0.47%) 2.12s (± 0.70%) -0.01s (- 0.42%) 2.09s 2.16s
Bind Time 0.70s (± 0.68%) 0.70s (± 0.97%) +0.00s (+ 0.14%) 0.69s 0.72s
Check Time 12.65s (± 0.71%) 12.79s (± 0.91%) +0.14s (+ 1.09%) 12.56s 13.10s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.48s (± 0.61%) 15.61s (± 0.76%) +0.13s (+ 0.85%) 15.39s 15.91s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-198-generic
Architecturex64
Available Memory16 GB
Available Memory8 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)
Benchmark Name Iterations
Current 42556 10
Baseline master 10

@ahejlsberg
Copy link
Member Author

@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 2, 2021

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

Update: The results are in!

@amcasey
Copy link
Member

amcasey commented Feb 2, 2021

Yammer looks good 👍

@ahejlsberg
Copy link
Member Author

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 19, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 19, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 19, 2021

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 19, 2021

Heya @ahejlsberg, I've started to run the parallelized community code test suite on this PR at 3d6dbf4. 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 - master..42556

Metric master 42556 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 346,015k (± 0.02%) 346,209k (± 0.03%) +195k (+ 0.06%) 346,025k 346,482k
Parse Time 1.91s (± 0.42%) 1.91s (± 0.37%) -0.00s (- 0.05%) 1.90s 1.93s
Bind Time 0.82s (± 0.83%) 0.82s (± 0.63%) -0.00s (- 0.61%) 0.81s 0.83s
Check Time 4.93s (± 0.45%) 4.93s (± 0.52%) 0.00s ( 0.00%) 4.85s 4.99s
Emit Time 5.23s (± 0.42%) 5.23s (± 0.55%) +0.00s (+ 0.00%) 5.17s 5.29s
Total Time 12.90s (± 0.32%) 12.90s (± 0.33%) -0.00s (- 0.03%) 12.76s 12.95s
Compiler-Unions - node (v10.16.3, x64)
Memory used 214,462k (± 0.06%) 203,211k (± 0.07%) 🟩-11,251k (- 5.25%) 202,835k 203,439k
Parse Time 0.77s (± 0.62%) 0.78s (± 0.63%) +0.00s (+ 0.39%) 0.76s 0.78s
Bind Time 0.50s (± 0.94%) 0.49s (± 1.38%) -0.01s (- 1.00%) 0.48s 0.51s
Check Time 10.66s (± 0.32%) 7.17s (± 0.77%) 🟩-3.49s (-32.73%) 7.06s 7.31s
Emit Time 2.33s (± 1.38%) 2.34s (± 0.95%) +0.01s (+ 0.51%) 2.28s 2.38s
Total Time 14.26s (± 0.35%) 10.78s (± 0.45%) 🟩-3.48s (-24.39%) 10.68s 10.91s
Monaco - node (v10.16.3, x64)
Memory used 355,283k (± 0.02%) 350,654k (± 0.02%) -4,629k (- 1.30%) 350,502k 350,807k
Parse Time 1.54s (± 0.49%) 1.54s (± 0.24%) 0.00s ( 0.00%) 1.54s 1.55s
Bind Time 0.72s (± 0.69%) 0.72s (± 0.62%) -0.00s (- 0.41%) 0.71s 0.73s
Check Time 5.12s (± 0.46%) 4.73s (± 0.55%) 🟩-0.39s (- 7.68%) 4.67s 4.80s
Emit Time 2.78s (± 0.74%) 2.80s (± 1.11%) +0.01s (+ 0.50%) 2.74s 2.88s
Total Time 10.18s (± 0.40%) 9.79s (± 0.44%) 🟩-0.39s (- 3.81%) 9.70s 9.88s
TFS - node (v10.16.3, x64)
Memory used 308,158k (± 0.03%) 308,219k (± 0.03%) +61k (+ 0.02%) 308,039k 308,419k
Parse Time 1.21s (± 0.88%) 1.20s (± 0.56%) -0.00s (- 0.25%) 1.19s 1.22s
Bind Time 0.68s (± 0.59%) 0.68s (± 0.70%) -0.00s (- 0.59%) 0.67s 0.69s
Check Time 4.58s (± 0.56%) 4.60s (± 0.57%) +0.02s (+ 0.48%) 4.55s 4.67s
Emit Time 2.93s (± 0.75%) 2.91s (± 1.14%) -0.02s (- 0.58%) 2.84s 2.97s
Total Time 9.39s (± 0.51%) 9.39s (± 0.48%) +0.00s (+ 0.03%) 9.29s 9.50s
material-ui - node (v10.16.3, x64)
Memory used 495,559k (± 0.01%) 505,547k (± 0.01%) +9,988k (+ 2.02%) 505,371k 505,746k
Parse Time 1.98s (± 0.79%) 1.98s (± 0.40%) -0.00s (- 0.10%) 1.96s 2.00s
Bind Time 0.65s (± 1.30%) 0.65s (± 0.72%) -0.00s (- 0.15%) 0.64s 0.66s
Check Time 13.93s (± 0.37%) 14.04s (± 0.41%) +0.11s (+ 0.81%) 13.93s 14.14s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.56s (± 0.32%) 16.67s (± 0.34%) +0.11s (+ 0.65%) 16.57s 16.77s
Angular - node (v12.1.0, x64)
Memory used 323,657k (± 0.02%) 323,529k (± 0.12%) -128k (- 0.04%) 322,013k 323,992k
Parse Time 1.90s (± 0.53%) 1.90s (± 0.46%) -0.00s (- 0.21%) 1.88s 1.92s
Bind Time 0.80s (± 0.65%) 0.80s (± 0.69%) +0.00s (+ 0.38%) 0.79s 0.81s
Check Time 4.85s (± 0.46%) 4.87s (± 0.64%) +0.03s (+ 0.54%) 4.82s 4.97s
Emit Time 5.38s (± 0.45%) 5.45s (± 0.86%) +0.07s (+ 1.21%) 5.33s 5.56s
Total Time 12.93s (± 0.36%) 13.03s (± 0.44%) +0.09s (+ 0.71%) 12.92s 13.15s
Compiler-Unions - node (v12.1.0, x64)
Memory used 199,927k (± 0.05%) 189,842k (± 0.07%) 🟩-10,085k (- 5.04%) 189,337k 190,062k
Parse Time 0.77s (± 0.89%) 0.77s (± 0.99%) 0.00s ( 0.00%) 0.75s 0.79s
Bind Time 0.50s (± 1.34%) 0.50s (± 0.73%) -0.00s (- 0.20%) 0.49s 0.50s
Check Time 9.70s (± 0.82%) 6.67s (± 0.38%) 🟩-3.02s (-31.17%) 6.59s 6.72s
Emit Time 2.34s (± 0.96%) 2.36s (± 0.83%) +0.02s (+ 0.81%) 2.33s 2.40s
Total Time 13.30s (± 0.63%) 10.30s (± 0.32%) 🟩-3.00s (-22.55%) 10.22s 10.36s
Monaco - node (v12.1.0, x64)
Memory used 337,471k (± 0.02%) 333,242k (± 0.02%) -4,229k (- 1.25%) 333,129k 333,360k
Parse Time 1.53s (± 0.78%) 1.53s (± 0.45%) -0.00s (- 0.13%) 1.51s 1.54s
Bind Time 0.70s (± 0.74%) 0.70s (± 0.85%) +0.00s (+ 0.57%) 0.69s 0.72s
Check Time 4.89s (± 0.67%) 4.56s (± 0.60%) 🟩-0.33s (- 6.69%) 4.53s 4.65s
Emit Time 2.84s (± 1.12%) 2.85s (± 1.09%) +0.02s (+ 0.56%) 2.79s 2.95s
Total Time 9.96s (± 0.54%) 9.65s (± 0.50%) 🟩-0.31s (- 3.06%) 9.55s 9.77s
TFS - node (v12.1.0, x64)
Memory used 292,410k (± 0.03%) 292,358k (± 0.02%) -52k (- 0.02%) 292,194k 292,460k
Parse Time 1.23s (± 0.62%) 1.22s (± 0.79%) -0.01s (- 0.49%) 1.20s 1.25s
Bind Time 0.66s (± 0.84%) 0.66s (± 1.52%) -0.00s (- 0.15%) 0.64s 0.69s
Check Time 4.50s (± 0.58%) 4.51s (± 0.84%) +0.02s (+ 0.40%) 4.46s 4.60s
Emit Time 2.93s (± 1.04%) 2.93s (± 1.04%) -0.00s (- 0.00%) 2.86s 3.02s
Total Time 9.30s (± 0.44%) 9.32s (± 0.58%) +0.02s (+ 0.17%) 9.21s 9.44s
material-ui - node (v12.1.0, x64)
Memory used 472,685k (± 0.05%) 482,421k (± 0.06%) +9,736k (+ 2.06%) 481,318k 482,667k
Parse Time 1.99s (± 0.77%) 1.99s (± 0.52%) +0.00s (+ 0.15%) 1.97s 2.01s
Bind Time 0.64s (± 0.81%) 0.64s (± 0.52%) +0.00s (+ 0.16%) 0.63s 0.65s
Check Time 12.48s (± 0.72%) 12.52s (± 0.60%) +0.04s (+ 0.34%) 12.38s 12.76s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.11s (± 0.62%) 15.15s (± 0.51%) +0.05s (+ 0.30%) 15.01s 15.40s
Angular - node (v14.15.1, x64)
Memory used 322,168k (± 0.01%) 322,208k (± 0.07%) +40k (+ 0.01%) 321,256k 322,368k
Parse Time 1.90s (± 0.46%) 1.90s (± 0.70%) +0.00s (+ 0.11%) 1.87s 1.93s
Bind Time 0.86s (± 0.88%) 0.85s (± 0.43%) -0.00s (- 0.23%) 0.85s 0.86s
Check Time 4.85s (± 0.46%) 4.86s (± 0.85%) +0.01s (+ 0.17%) 4.81s 5.00s
Emit Time 5.47s (± 0.54%) 5.46s (± 0.63%) -0.01s (- 0.09%) 5.40s 5.54s
Total Time 13.07s (± 0.35%) 13.08s (± 0.53%) +0.00s (+ 0.02%) 12.95s 13.24s
Compiler-Unions - node (v14.15.1, x64)
Memory used 200,914k (± 0.57%) 191,190k (± 0.61%) 🟩-9,725k (- 4.84%) 189,592k 192,826k
Parse Time 0.79s (± 0.62%) 0.80s (± 0.56%) +0.00s (+ 0.50%) 0.79s 0.81s
Bind Time 0.53s (± 0.63%) 0.53s (± 0.42%) +0.00s (+ 0.19%) 0.53s 0.54s
Check Time 9.73s (± 0.72%) 6.65s (± 0.41%) 🟩-3.08s (-31.64%) 6.60s 6.71s
Emit Time 2.35s (± 1.22%) 2.31s (± 0.60%) -0.04s (- 1.83%) 2.28s 2.33s
Total Time 13.40s (± 0.63%) 10.29s (± 0.36%) 🟩-3.11s (-23.23%) 10.21s 10.37s
Monaco - node (v14.15.1, x64)
Memory used 336,858k (± 0.01%) 332,590k (± 0.01%) -4,268k (- 1.27%) 332,518k 332,691k
Parse Time 1.56s (± 0.90%) 1.56s (± 0.53%) -0.00s (- 0.26%) 1.54s 1.58s
Bind Time 0.73s (± 0.61%) 0.73s (± 1.15%) -0.00s (- 0.14%) 0.72s 0.76s
Check Time 4.84s (± 0.45%) 4.57s (± 0.44%) 🟩-0.28s (- 5.70%) 4.51s 4.61s
Emit Time 2.92s (± 0.58%) 2.90s (± 0.49%) -0.01s (- 0.51%) 2.87s 2.94s
Total Time 10.05s (± 0.32%) 9.75s (± 0.27%) -0.30s (- 2.97%) 9.68s 9.82s
TFS - node (v14.15.1, x64)
Memory used 291,533k (± 0.01%) 291,539k (± 0.01%) +6k (+ 0.00%) 291,484k 291,560k
Parse Time 1.24s (± 1.75%) 1.24s (± 0.70%) -0.01s (- 0.48%) 1.22s 1.26s
Bind Time 0.69s (± 0.86%) 0.70s (± 0.96%) +0.00s (+ 0.43%) 0.68s 0.71s
Check Time 4.50s (± 0.26%) 4.49s (± 0.32%) -0.00s (- 0.09%) 4.46s 4.52s
Emit Time 3.06s (± 0.66%) 3.04s (± 0.89%) -0.02s (- 0.59%) 2.99s 3.10s
Total Time 9.49s (± 0.39%) 9.47s (± 0.35%) -0.03s (- 0.27%) 9.39s 9.52s
material-ui - node (v14.15.1, x64)
Memory used 471,405k (± 0.05%) 481,177k (± 0.00%) +9,772k (+ 2.07%) 481,131k 481,215k
Parse Time 2.05s (± 0.56%) 2.06s (± 0.59%) +0.00s (+ 0.15%) 2.03s 2.08s
Bind Time 0.70s (± 0.64%) 0.70s (± 0.63%) +0.00s (+ 0.57%) 0.69s 0.71s
Check Time 12.57s (± 0.52%) 12.62s (± 0.34%) +0.05s (+ 0.41%) 12.52s 12.71s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.32s (± 0.48%) 15.38s (± 0.27%) +0.06s (+ 0.37%) 15.28s 15.47s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-198-generic
Architecturex64
Available Memory16 GB
Available Memory7 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 42556 10
Baseline master 10

@ahejlsberg
Copy link
Member Author

Latest commits introduce caching and discriminant checks in subtype reduction and remove the 100 constituent limit I was experimenting with. Reduction in check time for Compiler-with-unions is now at 32%!

# Conflicts:
#	src/compiler/checker.ts
@armano2
Copy link

armano2 commented Feb 21, 2021

hello, i'd like to test this PR with typescript-eslint can i request a tgz? >

@typescript-bot pack this

@weswigham
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 21, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 21, 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/96510/artifacts?artifactName=tgz&fileId=6E2F5028E11836D8AC92A47A502585ED725124349FB64D6F6C1341703E28B46502&fileName=/typescript-4.3.0-insiders.20210221.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-42556-57".;

}
}
}
return count >= 10 && count * 2 >= types.length ? map : undefined;
Copy link
Member

Choose a reason for hiding this comment

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

To bring this in line with the comments above:

Suggested change
return count >= 10 && count * 2 >= types.length ? map : undefined;
return count < 10 || types.length < count * 2 ? undefined : map;

// Entries with duplicate keys have unknownType as the value.
function mapTypesByKeyProperty(types: Type[], name: __String) {
const map = new Map<TypeId, Type>();
let count = 0;
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
let count = 0;
// The count of types with unique keys.
let count = 0;

const objectFlags = getObjectFlags(type);
if (objectFlags & ObjectFlags.ObjectLiteral) {
const props = getPropertiesOfObjectType(type);
const propTypes = map(props, p => getInternedType(getTypeOfSymbol(p)));
Copy link
Member

Choose a reason for hiding this comment

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

Does this cause us to be any more eager in resolving method types than before?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. Method types aren't marked with ObjectFlags.ArrayLiteral or ObjectFlags.ObjectLiteral so they're not explored and therefore not resolved.

* with references to a single one of those types. The process is applied recursively to properties of
* object literals and elements of array literals.
*/
function deduplicateObjectOrArrayLiteralTypes(types: Type[]) {
Copy link
Member

Choose a reason for hiding this comment

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

We had discussed issues around circular types in object literal methods/getters in a past design meeting - do those concerns not apply here?

Copy link
Member Author

Choose a reason for hiding this comment

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

They do not. See my reply above.

@ahejlsberg
Copy link
Member Author

@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 28, 2021

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 28, 2021

Heya @ahejlsberg, I've started to run the perf test suite on this PR at a18aac2. 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 - master..42556

Metric master 42556 Delta Best Worst
Angular - node (v14.15.1, x64)
Memory used 322,936k (± 0.00%) 325,476k (± 0.01%) +2,541k (+ 0.79%) 325,427k 325,573k
Parse Time 1.92s (± 0.68%) 1.91s (± 0.51%) -0.01s (- 0.31%) 1.89s 1.93s
Bind Time 0.86s (± 0.60%) 0.86s (± 0.77%) +0.00s (+ 0.23%) 0.85s 0.88s
Check Time 4.86s (± 0.41%) 4.91s (± 0.51%) +0.05s (+ 1.05%) 4.84s 4.96s
Emit Time 5.99s (± 0.60%) 5.97s (± 0.40%) -0.02s (- 0.28%) 5.93s 6.03s
Total Time 13.62s (± 0.36%) 13.65s (± 0.12%) +0.03s (+ 0.21%) 13.61s 13.68s
Compiler-Unions - node (v14.15.1, x64)
Memory used 199,968k (± 0.11%) 190,560k (± 0.01%) 🟩-9,409k (- 4.71%) 190,514k 190,601k
Parse Time 0.80s (± 0.46%) 0.79s (± 0.28%) -0.00s (- 0.63%) 0.79s 0.80s
Bind Time 0.55s (± 1.01%) 0.55s (± 0.73%) -0.00s (- 0.18%) 0.54s 0.56s
Check Time 9.84s (± 0.51%) 6.93s (± 0.64%) 🟩-2.92s (-29.64%) 6.87s 7.04s
Emit Time 2.57s (± 0.98%) 2.52s (± 0.48%) -0.05s (- 2.14%) 2.49s 2.55s
Total Time 13.77s (± 0.44%) 10.79s (± 0.36%) 🟩-2.98s (-21.63%) 10.74s 10.88s
Monaco - node (v14.15.1, x64)
Memory used 337,253k (± 0.01%) 337,978k (± 0.01%) +726k (+ 0.22%) 337,916k 338,022k
Parse Time 1.56s (± 0.60%) 1.55s (± 0.42%) -0.01s (- 0.70%) 1.54s 1.56s
Bind Time 0.75s (± 0.64%) 0.74s (± 0.66%) -0.00s (- 0.40%) 0.74s 0.76s
Check Time 4.96s (± 0.41%) 4.93s (± 0.39%) -0.03s (- 0.52%) 4.89s 4.97s
Emit Time 3.14s (± 0.77%) 3.13s (± 0.67%) -0.01s (- 0.35%) 3.10s 3.19s
Total Time 10.41s (± 0.36%) 10.36s (± 0.18%) -0.05s (- 0.45%) 10.32s 10.40s
TFS - node (v14.15.1, x64)
Memory used 291,944k (± 0.01%) 292,206k (± 0.01%) +262k (+ 0.09%) 292,121k 292,250k
Parse Time 1.26s (± 2.03%) 1.24s (± 1.01%) -0.02s (- 1.35%) 1.22s 1.27s
Bind Time 0.72s (± 0.81%) 0.72s (± 0.93%) +0.00s (+ 0.00%) 0.70s 0.73s
Check Time 4.59s (± 0.47%) 4.57s (± 0.58%) -0.02s (- 0.46%) 4.52s 4.62s
Emit Time 3.21s (± 0.64%) 3.19s (± 0.67%) -0.01s (- 0.34%) 3.15s 3.24s
Total Time 9.77s (± 0.40%) 9.73s (± 0.34%) -0.05s (- 0.47%) 9.68s 9.81s
material-ui - node (v14.15.1, x64)
Memory used 468,701k (± 0.00%) 478,232k (± 0.07%) +9,532k (+ 2.03%) 477,380k 478,566k
Parse Time 2.06s (± 0.82%) 2.06s (± 0.94%) -0.01s (- 0.29%) 2.02s 2.11s
Bind Time 0.70s (± 0.83%) 0.69s (± 0.49%) -0.00s (- 0.57%) 0.69s 0.70s
Check Time 12.85s (± 0.63%) 12.94s (± 0.75%) +0.08s (+ 0.65%) 12.81s 13.20s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.62s (± 0.49%) 15.69s (± 0.62%) +0.07s (+ 0.46%) 15.58s 15.94s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-198-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)
Benchmark Name Iterations
Current 42556 10
Baseline master 10

Developer Information:

Download Benchmark

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..42556

Metric master 42556 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 346,548k (± 0.02%) 349,153k (± 0.02%) +2,605k (+ 0.75%) 349,003k 349,302k
Parse Time 1.93s (± 0.50%) 1.91s (± 0.47%) -0.02s (- 0.83%) 1.90s 1.94s
Bind Time 0.83s (± 0.59%) 0.84s (± 0.79%) +0.01s (+ 0.72%) 0.83s 0.86s
Check Time 5.02s (± 0.61%) 5.06s (± 0.51%) +0.04s (+ 0.80%) 4.98s 5.10s
Emit Time 5.66s (± 0.60%) 5.71s (± 0.75%) +0.05s (+ 0.79%) 5.61s 5.78s
Total Time 13.45s (± 0.37%) 13.52s (± 0.42%) +0.08s (+ 0.57%) 13.37s 13.61s
Compiler-Unions - node (v10.16.3, x64)
Memory used 215,207k (± 0.03%) 204,181k (± 0.04%) 🟩-11,026k (- 5.12%) 203,944k 204,318k
Parse Time 0.78s (± 0.79%) 0.78s (± 0.99%) 0.00s ( 0.00%) 0.77s 0.80s
Bind Time 0.52s (± 1.58%) 0.51s (± 1.30%) -0.01s (- 2.10%) 0.50s 0.52s
Check Time 10.82s (± 0.80%) 7.39s (± 0.53%) 🟩-3.44s (-31.74%) 7.31s 7.49s
Emit Time 2.56s (± 0.65%) 2.53s (± 0.69%) -0.03s (- 1.33%) 2.50s 2.59s
Total Time 14.69s (± 0.64%) 11.22s (± 0.41%) 🟩-3.48s (-23.66%) 11.12s 11.33s
Monaco - node (v10.16.3, x64)
Memory used 355,823k (± 0.02%) 356,619k (± 0.03%) +796k (+ 0.22%) 356,407k 356,933k
Parse Time 1.56s (± 0.57%) 1.55s (± 0.43%) -0.01s (- 0.70%) 1.54s 1.57s
Bind Time 0.74s (± 0.75%) 0.73s (± 0.67%) -0.00s (- 0.54%) 0.72s 0.74s
Check Time 5.19s (± 0.54%) 5.19s (± 0.34%) -0.00s (- 0.02%) 5.15s 5.22s
Emit Time 3.12s (± 0.69%) 3.08s (± 0.59%) -0.04s (- 1.19%) 3.05s 3.13s
Total Time 10.61s (± 0.33%) 10.56s (± 0.29%) -0.05s (- 0.46%) 10.50s 10.65s
TFS - node (v10.16.3, x64)
Memory used 308,681k (± 0.02%) 308,867k (± 0.02%) +186k (+ 0.06%) 308,752k 308,988k
Parse Time 1.21s (± 0.68%) 1.21s (± 0.37%) -0.01s (- 0.49%) 1.20s 1.22s
Bind Time 0.70s (± 0.88%) 0.69s (± 0.32%) -0.01s (- 1.71%) 0.68s 0.69s
Check Time 4.66s (± 0.56%) 4.65s (± 0.23%) -0.01s (- 0.17%) 4.63s 4.67s
Emit Time 3.20s (± 0.80%) 3.18s (± 0.57%) -0.02s (- 0.56%) 3.13s 3.21s
Total Time 9.78s (± 0.47%) 9.73s (± 0.24%) -0.04s (- 0.42%) 9.69s 9.79s
material-ui - node (v10.16.3, x64)
Memory used 492,019k (± 0.03%) 502,096k (± 0.02%) +10,077k (+ 2.05%) 501,896k 502,278k
Parse Time 2.00s (± 0.56%) 2.00s (± 0.67%) -0.00s (- 0.15%) 1.97s 2.02s
Bind Time 0.65s (± 1.16%) 0.65s (± 0.99%) -0.00s (- 0.31%) 0.64s 0.67s
Check Time 14.26s (± 0.72%) 14.25s (± 0.80%) -0.01s (- 0.06%) 13.98s 14.46s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.91s (± 0.58%) 16.90s (± 0.70%) -0.01s (- 0.07%) 16.62s 17.13s
Angular - node (v12.1.0, x64)
Memory used 324,207k (± 0.02%) 326,777k (± 0.02%) +2,570k (+ 0.79%) 326,595k 326,871k
Parse Time 1.91s (± 0.68%) 1.90s (± 0.69%) -0.01s (- 0.63%) 1.88s 1.93s
Bind Time 0.82s (± 0.93%) 0.81s (± 0.74%) -0.01s (- 1.10%) 0.79s 0.82s
Check Time 4.91s (± 0.64%) 4.93s (± 0.62%) +0.02s (+ 0.43%) 4.86s 5.01s
Emit Time 5.75s (± 0.81%) 5.70s (± 0.60%) -0.05s (- 0.83%) 5.61s 5.77s
Total Time 13.38s (± 0.45%) 13.34s (± 0.46%) -0.04s (- 0.34%) 13.19s 13.46s
Compiler-Unions - node (v12.1.0, x64)
Memory used 200,478k (± 0.05%) 190,816k (± 0.02%) 🟩-9,662k (- 4.82%) 190,681k 190,949k
Parse Time 0.77s (± 0.91%) 0.77s (± 0.58%) -0.00s (- 0.39%) 0.76s 0.78s
Bind Time 0.53s (± 0.65%) 0.53s (± 0.69%) -0.00s (- 0.19%) 0.52s 0.53s
Check Time 9.96s (± 0.82%) 6.93s (± 0.76%) 🟩-3.03s (-30.39%) 6.83s 7.04s
Emit Time 2.54s (± 0.94%) 2.53s (± 0.92%) -0.01s (- 0.51%) 2.46s 2.58s
Total Time 13.80s (± 0.70%) 10.76s (± 0.67%) 🟩-3.04s (-22.05%) 10.61s 10.92s
Monaco - node (v12.1.0, x64)
Memory used 338,287k (± 0.01%) 339,002k (± 0.03%) +715k (+ 0.21%) 338,821k 339,234k
Parse Time 1.55s (± 0.68%) 1.53s (± 0.34%) -0.02s (- 1.35%) 1.52s 1.54s
Bind Time 0.72s (± 1.13%) 0.72s (± 1.22%) -0.00s (- 0.41%) 0.71s 0.75s
Check Time 5.00s (± 0.30%) 5.03s (± 0.50%) +0.03s (+ 0.50%) 4.97s 5.08s
Emit Time 3.10s (± 0.93%) 3.08s (± 0.74%) -0.03s (- 0.87%) 3.02s 3.13s
Total Time 10.38s (± 0.36%) 10.35s (± 0.34%) -0.03s (- 0.31%) 10.28s 10.43s
TFS - node (v12.1.0, x64)
Memory used 292,857k (± 0.02%) 293,103k (± 0.02%) +246k (+ 0.08%) 292,994k 293,293k
Parse Time 1.23s (± 0.79%) 1.23s (± 0.48%) -0.00s (- 0.24%) 1.21s 1.24s
Bind Time 0.69s (± 1.22%) 0.68s (± 1.09%) -0.01s (- 1.31%) 0.66s 0.70s
Check Time 4.60s (± 0.36%) 4.58s (± 0.68%) -0.01s (- 0.26%) 4.52s 4.65s
Emit Time 3.14s (± 0.53%) 3.14s (± 0.60%) -0.00s (- 0.10%) 3.09s 3.18s
Total Time 9.65s (± 0.19%) 9.63s (± 0.36%) -0.02s (- 0.21%) 9.53s 9.69s
material-ui - node (v12.1.0, x64)
Memory used 469,968k (± 0.08%) 479,688k (± 0.08%) +9,720k (+ 2.07%) 478,725k 480,127k
Parse Time 2.01s (± 0.62%) 1.99s (± 0.37%) -0.02s (- 0.85%) 1.97s 2.01s
Bind Time 0.65s (± 0.76%) 0.64s (± 1.21%) -0.01s (- 1.08%) 0.62s 0.65s
Check Time 12.90s (± 0.96%) 12.96s (± 1.16%) +0.05s (+ 0.40%) 12.65s 13.29s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.55s (± 0.74%) 15.59s (± 1.00%) +0.04s (+ 0.23%) 15.27s 15.94s
Angular - node (v14.15.1, x64)
Memory used 322,936k (± 0.00%) 325,498k (± 0.01%) +2,563k (+ 0.79%) 325,428k 325,555k
Parse Time 1.92s (± 0.68%) 1.91s (± 0.41%) -0.00s (- 0.21%) 1.90s 1.93s
Bind Time 0.86s (± 0.60%) 0.86s (± 0.68%) -0.00s (- 0.46%) 0.84s 0.87s
Check Time 4.86s (± 0.41%) 4.91s (± 0.56%) +0.05s (+ 1.07%) 4.86s 4.96s
Emit Time 5.99s (± 0.60%) 5.95s (± 0.42%) -0.04s (- 0.63%) 5.87s 5.99s
Total Time 13.62s (± 0.36%) 13.63s (± 0.22%) +0.01s (+ 0.04%) 13.59s 13.72s
Compiler-Unions - node (v14.15.1, x64)
Memory used 199,968k (± 0.11%) 190,541k (± 0.01%) 🟩-9,427k (- 4.71%) 190,495k 190,586k
Parse Time 0.80s (± 0.46%) 0.80s (± 0.73%) +0.00s (+ 0.13%) 0.79s 0.81s
Bind Time 0.55s (± 1.01%) 0.55s (± 0.00%) -0.00s (- 0.36%) 0.55s 0.55s
Check Time 9.84s (± 0.51%) 6.93s (± 0.62%) 🟩-2.91s (-29.59%) 6.86s 7.04s
Emit Time 2.57s (± 0.98%) 2.51s (± 0.65%) -0.07s (- 2.56%) 2.48s 2.54s
Total Time 13.77s (± 0.44%) 10.79s (± 0.41%) 🟩-2.98s (-21.65%) 10.70s 10.92s
Monaco - node (v14.15.1, x64)
Memory used 337,253k (± 0.01%) 337,989k (± 0.00%) +736k (+ 0.22%) 337,960k 338,014k
Parse Time 1.56s (± 0.60%) 1.56s (± 0.61%) -0.01s (- 0.38%) 1.54s 1.58s
Bind Time 0.75s (± 0.64%) 0.75s (± 1.04%) +0.00s (+ 0.27%) 0.74s 0.77s
Check Time 4.96s (± 0.41%) 4.95s (± 0.61%) -0.01s (- 0.12%) 4.89s 5.03s
Emit Time 3.14s (± 0.77%) 3.11s (± 0.49%) -0.04s (- 1.21%) 3.07s 3.13s
Total Time 10.41s (± 0.36%) 10.37s (± 0.32%) -0.04s (- 0.41%) 10.30s 10.43s
TFS - node (v14.15.1, x64)
Memory used 291,944k (± 0.01%) 292,192k (± 0.01%) +248k (+ 0.08%) 292,125k 292,235k
Parse Time 1.26s (± 2.03%) 1.26s (± 0.93%) -0.01s (- 0.48%) 1.23s 1.28s
Bind Time 0.72s (± 0.81%) 0.72s (± 0.69%) -0.00s (- 0.14%) 0.71s 0.73s
Check Time 4.59s (± 0.47%) 4.58s (± 0.52%) -0.02s (- 0.37%) 4.54s 4.63s
Emit Time 3.21s (± 0.64%) 3.20s (± 0.54%) -0.01s (- 0.31%) 3.17s 3.23s
Total Time 9.77s (± 0.40%) 9.74s (± 0.36%) -0.03s (- 0.32%) 9.69s 9.83s
material-ui - node (v14.15.1, x64)
Memory used 468,701k (± 0.00%) 478,495k (± 0.00%) +9,794k (+ 2.09%) 478,461k 478,529k
Parse Time 2.06s (± 0.82%) 2.05s (± 0.63%) -0.02s (- 0.92%) 2.02s 2.07s
Bind Time 0.70s (± 0.83%) 0.70s (± 0.49%) 0.00s ( 0.00%) 0.69s 0.70s
Check Time 12.85s (± 0.63%) 12.90s (± 0.61%) +0.05s (+ 0.37%) 12.79s 13.15s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.62s (± 0.49%) 15.64s (± 0.50%) +0.03s (+ 0.18%) 15.54s 15.90s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-198-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)
Benchmark Name Iterations
Current 42556 10
Baseline master 10

Developer Information:

Download Benchmark

@ahejlsberg
Copy link
Member Author

Last commit removes the deduplication code for array literals. With the subtype reduction optimizations, deduplication is less impactful and only affects very large array literals of object literals. The Monaco RWC project has one such array literal (58K+ lines) the check time for which drops from 0.4s to 0.2s when deduplicated. That's nice, but given the rarity of array literals of that size, I don't think the added complexity of the deduplication code is justified and I'm merging this PR without it. We can always add it in a separate PR if people feel otherwise.

@ahejlsberg ahejlsberg merged commit ef2c98f into master Mar 1, 2021
PR Backlog automation moved this from Needs merge to Done Mar 1, 2021
amcasey added a commit to amcasey/TypeScript that referenced this pull request May 4, 2021
PR microsoft#42556 was a nice optimization that dramatically sped up comparisons of discriminated unions.  Unfortunately, the cost of determining whether a union is discriminated can be prohibitively high.  In particular, an internal team with a very large repo saw their type count double and their memory usage increase from 6GB to 9GB, breaking their build.  This changes splits the difference by not trying to compute the property types of intersection types - a notoriously slow operation.
amcasey added a commit that referenced this pull request May 7, 2021
PR #42556 was a nice optimization that dramatically sped up comparisons of discriminated unions.  Unfortunately, the cost of determining whether a union is discriminated can be prohibitively high.  In particular, an internal team with a very large repo saw their type count double and their memory usage increase from 6GB to 9GB, breaking their build.  This changes splits the difference by not trying to compute the property types of intersection types - a notoriously slow operation.
@jakebailey jakebailey deleted the fix42522 branch November 7, 2022 17:38
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
PR Backlog
  
Done
Development

Successfully merging this pull request may close these issues.

Unexpected slowness initializing large array with discriminated union constituents
7 participants