Skip to content

Add a fastpath for comparing common mapped types like Pick which avoids manufacturing intermediate type identities #39696

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

Merged

Conversation

weswigham
Copy link
Member

@weswigham weswigham commented Jul 21, 2020

Fixes #39678

This reduces the cost of the copy method in #39678 from 3s to 0.3s (on my machine, at least). In harder numbers, the fastpath brings the type count in the example given in #39678 from 402k types manufactured during compilation down to 27k types (compared to 19k types without the copy method at all).

…ds manufacturing intermediate type identities
@weswigham
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 Jul 21, 2020

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 21, 2020

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 21, 2020

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 21, 2020

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

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

Metric master 39696 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 343,552k (± 0.02%) 343,058k (± 0.01%) -494k (- 0.14%) 342,972k 343,186k
Parse Time 2.01s (± 0.60%) 2.01s (± 0.91%) -0.01s (- 0.30%) 1.97s 2.05s
Bind Time 0.82s (± 0.61%) 0.81s (± 0.45%) -0.00s (- 0.12%) 0.81s 0.82s
Check Time 4.74s (± 0.62%) 4.76s (± 0.58%) +0.01s (+ 0.25%) 4.71s 4.84s
Emit Time 5.19s (± 1.50%) 5.18s (± 0.69%) -0.01s (- 0.27%) 5.11s 5.27s
Total Time 12.76s (± 0.79%) 12.75s (± 0.31%) -0.01s (- 0.09%) 12.66s 12.84s
Monaco - node (v10.16.3, x64)
Memory used 338,974k (± 0.02%) 338,954k (± 0.03%) -20k (- 0.01%) 338,776k 339,167k
Parse Time 1.58s (± 0.89%) 1.57s (± 0.57%) -0.01s (- 0.63%) 1.56s 1.59s
Bind Time 0.72s (± 0.51%) 0.71s (± 0.73%) -0.00s (- 0.70%) 0.70s 0.72s
Check Time 4.94s (± 0.78%) 4.88s (± 0.61%) -0.06s (- 1.13%) 4.83s 4.95s
Emit Time 2.76s (± 0.61%) 2.74s (± 0.57%) -0.02s (- 0.69%) 2.71s 2.77s
Total Time 10.00s (± 0.54%) 9.91s (± 0.33%) -0.09s (- 0.89%) 9.84s 9.97s
TFS - node (v10.16.3, x64)
Memory used 301,995k (± 0.03%) 301,925k (± 0.02%) -71k (- 0.02%) 301,864k 302,099k
Parse Time 1.21s (± 0.37%) 1.21s (± 0.46%) +0.00s (+ 0.00%) 1.20s 1.23s
Bind Time 0.67s (± 0.83%) 0.67s (± 0.86%) +0.00s (+ 0.15%) 0.66s 0.69s
Check Time 4.45s (± 0.60%) 4.41s (± 0.48%) -0.04s (- 0.81%) 4.35s 4.46s
Emit Time 2.89s (± 1.13%) 2.90s (± 1.00%) +0.01s (+ 0.45%) 2.84s 2.98s
Total Time 9.22s (± 0.58%) 9.20s (± 0.38%) -0.03s (- 0.27%) 9.11s 9.27s
material-ui - node (v10.16.3, x64)
Memory used 459,087k (± 0.01%) 458,327k (± 0.02%) -760k (- 0.17%) 458,220k 458,496k
Parse Time 2.06s (± 0.67%) 2.04s (± 0.67%) -0.01s (- 0.54%) 2.02s 2.08s
Bind Time 0.65s (± 0.95%) 0.64s (± 1.48%) -0.01s (- 1.08%) 0.63s 0.67s
Check Time 12.96s (± 0.96%) 12.82s (± 0.33%) -0.14s (- 1.06%) 12.71s 12.93s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.67s (± 0.82%) 15.51s (± 0.33%) -0.15s (- 0.99%) 15.38s 15.60s
Angular - node (v12.1.0, x64)
Memory used 320,807k (± 0.03%) 320,426k (± 0.02%) -381k (- 0.12%) 320,323k 320,627k
Parse Time 1.99s (± 0.67%) 2.00s (± 0.47%) +0.00s (+ 0.20%) 1.97s 2.02s
Bind Time 0.80s (± 0.87%) 0.81s (± 1.42%) +0.01s (+ 1.12%) 0.80s 0.85s
Check Time 4.66s (± 0.63%) 4.64s (± 0.48%) -0.02s (- 0.43%) 4.60s 4.69s
Emit Time 5.35s (± 0.53%) 5.34s (± 0.47%) -0.00s (- 0.09%) 5.29s 5.41s
Total Time 12.80s (± 0.43%) 12.78s (± 0.29%) -0.02s (- 0.12%) 12.70s 12.87s
Monaco - node (v12.1.0, x64)
Memory used 321,500k (± 0.02%) 321,448k (± 0.02%) -52k (- 0.02%) 321,237k 321,564k
Parse Time 1.56s (± 0.74%) 1.54s (± 0.96%) -0.02s (- 1.34%) 1.50s 1.56s
Bind Time 0.69s (± 0.65%) 0.69s (± 0.84%) -0.00s (- 0.15%) 0.68s 0.70s
Check Time 4.72s (± 0.71%) 4.71s (± 0.52%) -0.01s (- 0.15%) 4.65s 4.77s
Emit Time 2.80s (± 0.46%) 2.79s (± 0.61%) -0.01s (- 0.39%) 2.76s 2.84s
Total Time 9.77s (± 0.47%) 9.73s (± 0.31%) -0.04s (- 0.40%) 9.67s 9.80s
TFS - node (v12.1.0, x64)
Memory used 286,527k (± 0.02%) 286,468k (± 0.02%) -59k (- 0.02%) 286,345k 286,613k
Parse Time 1.24s (± 0.36%) 1.22s (± 0.72%) -0.02s (- 1.53%) 1.21s 1.24s
Bind Time 0.64s (± 0.87%) 0.64s (± 0.75%) -0.00s (- 0.16%) 0.63s 0.65s
Check Time 4.33s (± 0.61%) 4.31s (± 0.37%) -0.02s (- 0.51%) 4.28s 4.35s
Emit Time 2.94s (± 0.64%) 2.90s (± 0.57%) -0.04s (- 1.33%) 2.85s 2.93s
Total Time 9.16s (± 0.46%) 9.07s (± 0.25%) -0.08s (- 0.88%) 9.03s 9.14s
material-ui - node (v12.1.0, x64)
Memory used 437,422k (± 0.05%) 436,859k (± 0.02%) -563k (- 0.13%) 436,712k 437,006k
Parse Time 2.04s (± 0.71%) 2.02s (± 0.44%) -0.02s (- 0.93%) 2.00s 2.04s
Bind Time 0.63s (± 0.71%) 0.63s (± 1.22%) -0.01s (- 1.11%) 0.61s 0.64s
Check Time 11.71s (± 0.84%) 11.60s (± 1.05%) -0.10s (- 0.90%) 11.44s 12.02s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 14.38s (± 0.71%) 14.24s (± 0.91%) -0.14s (- 0.94%) 14.05s 14.69s
Angular - node (v8.9.0, x64)
Memory used 340,104k (± 0.01%) 339,733k (± 0.01%) -371k (- 0.11%) 339,654k 339,809k
Parse Time 2.54s (± 0.47%) 2.53s (± 0.42%) -0.00s (- 0.12%) 2.52s 2.56s
Bind Time 0.85s (± 0.61%) 0.85s (± 0.70%) -0.00s (- 0.35%) 0.83s 0.86s
Check Time 5.40s (± 0.56%) 5.36s (± 0.57%) -0.05s (- 0.85%) 5.29s 5.42s
Emit Time 5.90s (± 1.41%) 5.90s (± 1.16%) -0.00s (- 0.05%) 5.69s 6.07s
Total Time 14.69s (± 0.54%) 14.63s (± 0.62%) -0.06s (- 0.38%) 14.46s 14.88s
Monaco - node (v8.9.0, x64)
Memory used 340,340k (± 0.02%) 340,332k (± 0.01%) -8k (- 0.00%) 340,237k 340,448k
Parse Time 1.87s (± 0.48%) 1.87s (± 0.32%) +0.00s (+ 0.00%) 1.86s 1.89s
Bind Time 0.89s (± 0.54%) 0.89s (± 0.87%) +0.00s (+ 0.45%) 0.87s 0.91s
Check Time 5.47s (± 0.66%) 5.42s (± 0.67%) -0.04s (- 0.77%) 5.37s 5.52s
Emit Time 3.22s (± 0.78%) 3.25s (± 1.00%) +0.03s (+ 0.96%) 3.19s 3.32s
Total Time 11.45s (± 0.44%) 11.44s (± 0.51%) -0.01s (- 0.08%) 11.32s 11.60s
TFS - node (v8.9.0, x64)
Memory used 303,729k (± 0.01%) 303,727k (± 0.01%) -1k (- 0.00%) 303,637k 303,796k
Parse Time 1.54s (± 0.44%) 1.55s (± 0.36%) +0.00s (+ 0.26%) 1.54s 1.56s
Bind Time 0.67s (± 0.71%) 0.67s (± 0.83%) -0.00s (- 0.15%) 0.66s 0.68s
Check Time 5.08s (± 1.38%) 5.13s (± 1.57%) +0.05s (+ 0.96%) 4.95s 5.27s
Emit Time 3.06s (± 2.93%) 3.01s (± 2.56%) -0.05s (- 1.73%) 2.89s 3.21s
Total Time 10.36s (± 0.37%) 10.36s (± 0.55%) -0.01s (- 0.05%) 10.22s 10.47s
material-ui - node (v8.9.0, x64)
Memory used 463,313k (± 0.01%) 462,666k (± 0.01%) -647k (- 0.14%) 462,540k 462,830k
Parse Time 2.39s (± 0.35%) 2.39s (± 0.60%) +0.00s (+ 0.13%) 2.35s 2.43s
Bind Time 0.78s (± 1.38%) 0.77s (± 1.36%) -0.01s (- 0.77%) 0.76s 0.80s
Check Time 17.27s (± 0.81%) 17.24s (± 1.10%) -0.03s (- 0.16%) 16.62s 17.61s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 20.44s (± 0.71%) 20.41s (± 0.97%) -0.03s (- 0.14%) 19.78s 20.85s
Angular - node (v8.9.0, x86)
Memory used 195,162k (± 0.04%) 194,980k (± 0.01%) -182k (- 0.09%) 194,934k 195,043k
Parse Time 2.46s (± 0.60%) 2.44s (± 0.53%) -0.01s (- 0.57%) 2.42s 2.48s
Bind Time 0.99s (± 0.81%) 0.99s (± 0.95%) -0.00s (- 0.10%) 0.97s 1.00s
Check Time 4.84s (± 0.82%) 4.85s (± 0.42%) +0.01s (+ 0.31%) 4.80s 4.89s
Emit Time 5.91s (± 0.58%) 5.94s (± 0.58%) +0.03s (+ 0.51%) 5.89s 6.03s
Total Time 14.19s (± 0.46%) 14.22s (± 0.39%) +0.03s (+ 0.23%) 14.13s 14.36s
Monaco - node (v8.9.0, x86)
Memory used 193,450k (± 0.02%) 193,440k (± 0.02%) -10k (- 0.01%) 193,376k 193,535k
Parse Time 1.90s (± 0.44%) 1.92s (± 0.57%) +0.02s (+ 1.21%) 1.90s 1.95s
Bind Time 0.70s (± 0.57%) 0.70s (± 0.57%) -0.00s (- 0.29%) 0.69s 0.71s
Check Time 5.52s (± 0.40%) 5.47s (± 1.47%) -0.06s (- 1.05%) 5.22s 5.55s
Emit Time 2.66s (± 0.74%) 2.75s (± 3.98%) +0.08s (+ 3.12%) 2.64s 3.04s
Total Time 10.79s (± 0.30%) 10.83s (± 0.39%) +0.04s (+ 0.42%) 10.74s 10.95s
TFS - node (v8.9.0, x86)
Memory used 173,675k (± 0.02%) 173,718k (± 0.03%) +43k (+ 0.02%) 173,631k 173,830k
Parse Time 1.61s (± 1.22%) 1.58s (± 0.61%) -0.03s (- 1.68%) 1.56s 1.60s
Bind Time 0.64s (± 0.90%) 0.64s (± 0.92%) +0.00s (+ 0.16%) 0.64s 0.66s
Check Time 4.68s (± 0.53%) 4.69s (± 0.29%) +0.01s (+ 0.19%) 4.66s 4.72s
Emit Time 2.79s (± 1.18%) 2.78s (± 1.15%) -0.01s (- 0.22%) 2.70s 2.83s
Total Time 9.71s (± 0.60%) 9.69s (± 0.42%) -0.02s (- 0.22%) 9.58s 9.76s
material-ui - node (v8.9.0, x86)
Memory used 262,396k (± 0.01%) 262,031k (± 0.01%) -364k (- 0.14%) 261,940k 262,110k
Parse Time 2.45s (± 0.64%) 2.45s (± 0.59%) -0.00s (- 0.20%) 2.42s 2.49s
Bind Time 0.67s (± 1.67%) 0.66s (± 1.21%) -0.00s (- 0.60%) 0.65s 0.68s
Check Time 15.67s (± 0.66%) 15.71s (± 0.76%) +0.05s (+ 0.30%) 15.51s 15.99s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 18.78s (± 0.61%) 18.82s (± 0.64%) +0.04s (+ 0.19%) 18.61s 19.09s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-166-generic
Architecturex64
Available Memory16 GB
Available Memory1 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v8.9.0, x64)
  • node (v8.9.0, x86)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v8.9.0, x64)
  • Angular - node (v8.9.0, x86)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v8.9.0, x64)
  • Monaco - node (v8.9.0, x86)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v8.9.0, x64)
  • TFS - node (v8.9.0, x86)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v8.9.0, x64)
  • material-ui - node (v8.9.0, x86)
Benchmark Name Iterations
Current 39696 10
Baseline master 10

@weswigham
Copy link
Member Author

Perf looks good (potentially a small gain in material ui). Other suites are either passing or existing diffs.

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 22, 2020

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 22, 2020

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/80397/artifacts?artifactName=tgz&fileId=14654A0919A2754C6F6A37793A75B713EE27FAA319C72095DBD71314934A499702&fileName=/typescript-4.0.0-insiders.20200722.tgz"
    }
}

and then running npm install.


There is also a playground for this build.

@weswigham
Copy link
Member Author

@nscarcella you wanna try this PR build to verify that if fixes your actual code?

@nscarcella
Copy link

@nscarcella you wanna try this PR build to verify that if fixes your actual code?

For the simplified model described in #39678 these changes reduce the amount of types from 521712(6.59s) to 404755(4.60s).

Can't currently test it on the whole model because we can't update the TypeScript version due to this other issue.

@weswigham weswigham merged commit 312a6f0 into microsoft:master Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slow compilation likely caused by too many types
4 participants