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

Better best effort type alias preservation #40232

Closed
wants to merge 4 commits into from

Conversation

weswigham
Copy link
Member

@weswigham weswigham commented Aug 25, 2020

In this PR, we record all[1] aliases we create for a type, rather than just the one we encounter on the adjacent declaration the first time we create a type, and then use that recorded list of aliases to improve declaration emit/printback in a more deterministic way.

Fixes #40092 and probably a lot of other stuff. I've labeled this as a potentially Breaking Change as the use of more aliases could affect people's declaration emit of inferred types - for example, the lib PropertyKey type is often used in place of string | number | symbol (since it's a global type alias).

[1]some aliases we could make, but likely just increase complexity, are intentionally omitted - this way we don't do things like printback NonNullable<NonNullable<T>> as a preferred "alias" of T.

@weswigham weswigham added the Breaking Change Would introduce errors in existing code label Aug 25, 2020
@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Aug 25, 2020
@weswigham
Copy link
Member Author

@typescript-bot perf test this (this almost certainly has a cost)
@typescript-bot user test this
@typescript-bot run dt

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 25, 2020

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 25, 2020

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 25, 2020

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 25, 2020

Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at 7d9bb77. 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..40232

Metric master 40232 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 344,453k (± 0.02%) 345,850k (± 0.01%) +1,397k (+ 0.41%) 345,753k 345,996k
Parse Time 2.02s (± 0.58%) 2.00s (± 0.50%) -0.02s (- 0.94%) 1.98s 2.03s
Bind Time 0.83s (± 1.89%) 0.82s (± 0.54%) -0.00s (- 0.48%) 0.81s 0.83s
Check Time 4.80s (± 0.62%) 4.79s (± 0.40%) -0.01s (- 0.19%) 4.75s 4.83s
Emit Time 5.18s (± 0.68%) 5.19s (± 0.56%) +0.01s (+ 0.14%) 5.11s 5.24s
Total Time 12.82s (± 0.54%) 12.79s (± 0.31%) -0.03s (- 0.21%) 12.71s 12.89s
Monaco - node (v10.16.3, x64)
Memory used 339,280k (± 0.04%) 339,566k (± 0.03%) +286k (+ 0.08%) 339,363k 339,795k
Parse Time 1.56s (± 0.89%) 1.55s (± 0.66%) -0.01s (- 0.45%) 1.53s 1.58s
Bind Time 0.71s (± 0.31%) 0.71s (± 0.63%) -0.00s (- 0.42%) 0.70s 0.72s
Check Time 4.95s (± 0.71%) 4.96s (± 0.43%) +0.01s (+ 0.24%) 4.92s 5.02s
Emit Time 2.74s (± 1.08%) 2.74s (± 0.52%) -0.01s (- 0.22%) 2.70s 2.76s
Total Time 9.96s (± 0.67%) 9.96s (± 0.36%) -0.00s (- 0.03%) 9.90s 10.07s
TFS - node (v10.16.3, x64)
Memory used 302,273k (± 0.03%) 302,596k (± 0.04%) +323k (+ 0.11%) 302,317k 302,782k
Parse Time 1.21s (± 0.56%) 1.21s (± 0.66%) +0.00s (+ 0.17%) 1.19s 1.23s
Bind Time 0.67s (± 1.04%) 0.67s (± 0.87%) -0.00s (- 0.60%) 0.65s 0.68s
Check Time 4.44s (± 0.83%) 4.46s (± 0.62%) +0.02s (+ 0.38%) 4.39s 4.54s
Emit Time 2.92s (± 0.72%) 2.89s (± 0.88%) -0.03s (- 1.03%) 2.84s 2.93s
Total Time 9.23s (± 0.65%) 9.22s (± 0.48%) -0.01s (- 0.14%) 9.12s 9.33s
material-ui - node (v10.16.3, x64)
Memory used 460,841k (± 0.01%) 475,192k (± 0.02%) +14,352k (+ 3.11%) 475,050k 475,388k
Parse Time 1.95s (± 0.30%) 1.95s (± 0.38%) +0.00s (+ 0.00%) 1.94s 1.97s
Bind Time 0.66s (± 1.10%) 0.66s (± 1.04%) -0.01s (- 0.91%) 0.64s 0.67s
Check Time 13.51s (± 0.84%) 15.67s (± 0.65%) +2.16s (+15.99%) 15.51s 15.95s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.13s (± 0.72%) 18.28s (± 0.58%) +2.16s (+13.36%) 18.12s 18.58s
Angular - node (v12.1.0, x64)
Memory used 321,740k (± 0.03%) 323,094k (± 0.03%) +1,353k (+ 0.42%) 322,936k 323,362k
Parse Time 1.99s (± 0.56%) 1.96s (± 0.54%) -0.03s (- 1.55%) 1.95s 2.00s
Bind Time 0.81s (± 0.61%) 0.80s (± 0.72%) -0.00s (- 0.37%) 0.79s 0.82s
Check Time 4.68s (± 0.56%) 4.67s (± 0.32%) -0.00s (- 0.09%) 4.65s 4.71s
Emit Time 5.36s (± 0.61%) 5.37s (± 0.58%) +0.01s (+ 0.22%) 5.33s 5.47s
Total Time 12.83s (± 0.45%) 12.81s (± 0.30%) -0.03s (- 0.21%) 12.74s 12.94s
Monaco - node (v12.1.0, x64)
Memory used 321,551k (± 0.01%) 322,056k (± 0.02%) +505k (+ 0.16%) 321,900k 322,223k
Parse Time 1.53s (± 0.74%) 1.52s (± 1.02%) -0.01s (- 0.39%) 1.50s 1.58s
Bind Time 0.69s (± 0.81%) 0.69s (± 0.98%) +0.01s (+ 0.87%) 0.69s 0.72s
Check Time 4.74s (± 0.30%) 4.74s (± 0.49%) -0.00s (- 0.04%) 4.68s 4.79s
Emit Time 2.79s (± 0.66%) 2.79s (± 0.47%) +0.00s (+ 0.14%) 2.77s 2.82s
Total Time 9.75s (± 0.42%) 9.75s (± 0.30%) +0.00s (+ 0.01%) 9.69s 9.83s
TFS - node (v12.1.0, x64)
Memory used 286,603k (± 0.03%) 286,952k (± 0.02%) +349k (+ 0.12%) 286,842k 287,165k
Parse Time 1.23s (± 1.05%) 1.23s (± 0.48%) -0.00s (- 0.08%) 1.22s 1.24s
Bind Time 0.64s (± 0.87%) 0.64s (± 0.73%) +0.00s (+ 0.31%) 0.63s 0.65s
Check Time 4.36s (± 0.48%) 4.35s (± 0.30%) -0.00s (- 0.05%) 4.32s 4.37s
Emit Time 2.93s (± 0.62%) 2.91s (± 0.75%) -0.02s (- 0.58%) 2.87s 2.97s
Total Time 9.15s (± 0.36%) 9.13s (± 0.33%) -0.02s (- 0.21%) 9.05s 9.20s
material-ui - node (v12.1.0, x64)
Memory used 439,051k (± 0.07%) 453,066k (± 0.07%) +14,014k (+ 3.19%) 452,273k 453,736k
Parse Time 1.99s (± 0.48%) 1.96s (± 0.38%) -0.03s (- 1.31%) 1.94s 1.97s
Bind Time 0.64s (± 0.70%) 0.62s (± 0.93%) -0.02s (- 2.82%) 0.61s 0.63s
Check Time 12.02s (± 0.80%) 14.24s (± 1.07%) +2.22s (+18.47%) 13.99s 14.56s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 14.64s (± 0.69%) 16.82s (± 0.90%) +2.18s (+14.88%) 16.59s 17.14s
Angular - node (v8.9.0, x64)
Memory used 341,072k (± 0.01%) 342,389k (± 0.01%) +1,317k (+ 0.39%) 342,280k 342,488k
Parse Time 2.55s (± 0.51%) 2.54s (± 0.42%) -0.01s (- 0.39%) 2.52s 2.56s
Bind Time 0.86s (± 1.34%) 0.85s (± 0.76%) -0.01s (- 1.40%) 0.83s 0.86s
Check Time 5.40s (± 0.89%) 5.46s (± 0.48%) +0.06s (+ 1.07%) 5.40s 5.51s
Emit Time 6.06s (± 1.48%) 5.93s (± 2.13%) -0.13s (- 2.23%) 5.68s 6.22s
Total Time 14.86s (± 0.72%) 14.77s (± 0.86%) -0.09s (- 0.63%) 14.48s 15.09s
Monaco - node (v8.9.0, x64)
Memory used 340,580k (± 0.01%) 341,083k (± 0.01%) +502k (+ 0.15%) 340,984k 341,169k
Parse Time 1.87s (± 0.56%) 1.88s (± 0.27%) +0.00s (+ 0.11%) 1.87s 1.89s
Bind Time 0.88s (± 0.53%) 0.88s (± 0.59%) +0.00s (+ 0.11%) 0.87s 0.89s
Check Time 5.48s (± 0.60%) 5.49s (± 0.50%) +0.01s (+ 0.20%) 5.44s 5.54s
Emit Time 3.19s (± 0.50%) 3.23s (± 0.39%) +0.04s (+ 1.13%) 3.20s 3.25s
Total Time 11.42s (± 0.32%) 11.47s (± 0.34%) +0.05s (+ 0.44%) 11.40s 11.55s
TFS - node (v8.9.0, x64)
Memory used 303,884k (± 0.02%) 304,227k (± 0.02%) +343k (+ 0.11%) 304,066k 304,317k
Parse Time 1.54s (± 0.45%) 1.55s (± 0.68%) +0.01s (+ 0.39%) 1.53s 1.57s
Bind Time 0.67s (± 0.86%) 0.67s (± 0.86%) -0.00s (- 0.00%) 0.66s 0.68s
Check Time 5.20s (± 0.56%) 5.22s (± 0.54%) +0.03s (+ 0.48%) 5.16s 5.30s
Emit Time 2.93s (± 0.63%) 2.93s (± 0.63%) +0.00s (+ 0.10%) 2.89s 2.96s
Total Time 10.33s (± 0.37%) 10.37s (± 0.37%) +0.03s (+ 0.31%) 10.28s 10.47s
material-ui - node (v8.9.0, x64)
Memory used 465,199k (± 0.01%) 479,916k (± 0.01%) +14,717k (+ 3.16%) 479,768k 480,127k
Parse Time 2.40s (± 0.46%) 2.38s (± 0.60%) -0.02s (- 0.67%) 2.36s 2.42s
Bind Time 0.77s (± 1.07%) 0.78s (± 1.35%) +0.01s (+ 0.78%) 0.76s 0.81s
Check Time 18.05s (± 0.77%) 22.71s (± 1.50%) +4.66s (+25.82%) 22.14s 23.49s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 21.22s (± 0.68%) 25.87s (± 1.36%) +4.65s (+21.91%) 25.27s 26.69s
Angular - node (v8.9.0, x86)
Memory used 195,727k (± 0.01%) 196,338k (± 0.02%) +612k (+ 0.31%) 196,267k 196,411k
Parse Time 2.46s (± 0.56%) 2.46s (± 0.59%) -0.00s (- 0.12%) 2.42s 2.49s
Bind Time 1.00s (± 0.80%) 0.99s (± 0.74%) -0.01s (- 1.40%) 0.98s 1.01s
Check Time 4.89s (± 0.52%) 4.89s (± 0.63%) -0.00s (- 0.04%) 4.83s 4.98s
Emit Time 5.95s (± 0.90%) 5.98s (± 1.18%) +0.03s (+ 0.54%) 5.90s 6.20s
Total Time 14.30s (± 0.47%) 14.31s (± 0.76%) +0.01s (+ 0.07%) 14.19s 14.69s
Monaco - node (v8.9.0, x86)
Memory used 193,625k (± 0.02%) 193,885k (± 0.02%) +261k (+ 0.13%) 193,805k 194,009k
Parse Time 1.92s (± 0.78%) 1.90s (± 0.58%) -0.01s (- 0.68%) 1.89s 1.93s
Bind Time 0.70s (± 0.95%) 0.70s (± 0.71%) -0.00s (- 0.57%) 0.69s 0.71s
Check Time 5.57s (± 0.59%) 5.61s (± 0.62%) +0.04s (+ 0.63%) 5.54s 5.70s
Emit Time 2.67s (± 0.92%) 2.67s (± 1.29%) -0.01s (- 0.26%) 2.63s 2.79s
Total Time 10.86s (± 0.51%) 10.88s (± 0.48%) +0.01s (+ 0.11%) 10.76s 11.00s
TFS - node (v8.9.0, x86)
Memory used 173,848k (± 0.03%) 174,057k (± 0.03%) +209k (+ 0.12%) 173,951k 174,250k
Parse Time 1.59s (± 0.84%) 1.59s (± 0.96%) 0.00s ( 0.00%) 1.56s 1.64s
Bind Time 0.64s (± 0.62%) 0.64s (± 0.35%) 0.00s ( 0.00%) 0.64s 0.65s
Check Time 4.72s (± 0.60%) 4.74s (± 0.65%) +0.02s (+ 0.34%) 4.65s 4.78s
Emit Time 2.80s (± 1.20%) 2.79s (± 0.68%) -0.01s (- 0.39%) 2.75s 2.83s
Total Time 9.75s (± 0.48%) 9.75s (± 0.53%) +0.01s (+ 0.05%) 9.63s 9.89s
material-ui - node (v8.9.0, x86)
Memory used 263,437k (± 0.01%) 270,938k (± 0.02%) +7,501k (+ 2.85%) 270,827k 271,045k
Parse Time 2.45s (± 0.68%) 2.45s (± 1.02%) -0.00s (- 0.08%) 2.40s 2.53s
Bind Time 0.67s (± 0.92%) 0.67s (± 1.52%) +0.00s (+ 0.30%) 0.66s 0.70s
Check Time 16.47s (± 0.76%) 21.10s (± 1.43%) +4.63s (+28.11%) 20.66s 21.86s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 19.59s (± 0.68%) 24.22s (± 1.22%) +4.63s (+23.63%) 23.73s 24.94s
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 40232 10
Baseline master 10

@martaver
Copy link

Does this PR address the non-propogation of type aliases described in point one in #45954, which makes proposals to Improve type readability?

@sandersn
Copy link
Member

Unfortunately, we never finished reviewing this PR. It is pretty old now, so I'm going to close it to reduce the number of open PRs.

@sandersn sandersn closed this May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team Breaking Change Would introduce errors in existing code For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

random emit declaration
5 participants