GeezerVison is showing github.com — Switch let/const to var in the scanner & parser for top-levelish variables. by DanielRosenwasser · Pull Request #52832 · microsoft/TypeScript
Conversation
This pull request regains some of the performance we lost in #51387 when we switched our emit from ES5 to ES2018 - a significant part due to TDZ checks that engines need to perform. These TDZ checks can often be eliminated, but engines probably have a hard time knowing whether a function can eliminate these checks.
By switching many of the top-level shared closure variables in the parser and scanner from let/const to var, we're able to eliminate those checks. Doing so should be fairly safe, since our functions follow the same initialization mechanism of declaring variables, and then calling the "workhorse" function afterwards.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
robpalme, unional, paulirish, SlurpTheo, and alexandercerutti reacted with eyes emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Daniel Rosenwasser (@DanielRosenwasser)
The results of the perf run you requested are in!
Here they are:
Comparison Report - main..52832
| Metric |
main |
52832 |
Delta |
Best |
Worst |
p-value |
| Angular - node (v16.17.1, x64) |
| Memory used |
359,093k (± 0.01%) |
358,732k (± 0.00%) |
-361k (- 0.10%) |
358,719k |
358,755k |
p=0.005 n=6 |
| Parse Time |
4.16s (± 0.42%) |
3.72s (± 0.55%) |
🟩-0.44s (-10.61%) |
3.69s |
3.75s |
p=0.005 n=6 |
| Bind Time |
1.24s (± 0.33%) |
1.22s (± 0.68%) |
-0.02s (- 1.34%) |
1.22s |
1.24s |
p=0.009 n=6 |
| Check Time |
9.52s (± 0.44%) |
9.50s (± 0.25%) |
~ |
9.47s |
9.53s |
p=0.332 n=6 |
| Emit Time |
8.10s (± 0.68%) |
8.05s (± 0.51%) |
~ |
7.98s |
8.08s |
p=0.142 n=6 |
| Total Time |
23.02s (± 0.40%) |
22.50s (± 0.27%) |
-0.53s (- 2.28%) |
22.40s |
22.57s |
p=0.005 n=6 |
| Compiler-Unions - node (v16.17.1, x64) |
| Memory used |
191,731k (± 0.02%) |
191,531k (± 0.05%) |
-200k (- 0.10%) |
191,454k |
191,717k |
p=0.013 n=6 |
| Parse Time |
1.81s (± 0.97%) |
1.57s (± 0.35%) |
🟩-0.24s (-13.38%) |
1.56s |
1.57s |
p=0.004 n=6 |
| Bind Time |
0.84s (± 0.48%) |
0.84s (± 0.48%) |
~ |
0.84s |
0.85s |
p=1.000 n=6 |
| Check Time |
10.13s (± 0.70%) |
10.16s (± 0.69%) |
~ |
10.07s |
10.26s |
p=0.419 n=6 |
| Emit Time |
3.04s (± 0.70%) |
3.07s (± 1.41%) |
~ |
3.01s |
3.12s |
p=0.374 n=6 |
| Total Time |
15.82s (± 0.62%) |
15.63s (± 0.64%) |
-0.18s (- 1.16%) |
15.51s |
15.80s |
p=0.030 n=6 |
| Monaco - node (v16.17.1, x64) |
| Memory used |
343,537k (± 0.01%) |
343,235k (± 0.01%) |
-302k (- 0.09%) |
343,196k |
343,251k |
p=0.005 n=6 |
| Parse Time |
3.10s (± 0.53%) |
2.78s (± 0.42%) |
🟩-0.31s (-10.17%) |
2.77s |
2.80s |
p=0.005 n=6 |
| Bind Time |
1.11s (± 0.73%) |
1.11s (± 0.00%) |
~ |
1.11s |
1.11s |
p=0.290 n=6 |
| Check Time |
7.79s (± 0.70%) |
7.80s (± 0.38%) |
~ |
7.76s |
7.83s |
p=0.746 n=6 |
| Emit Time |
4.51s (± 0.33%) |
4.50s (± 0.50%) |
~ |
4.48s |
4.54s |
p=0.796 n=6 |
| Total Time |
16.51s (± 0.37%) |
16.20s (± 0.24%) |
-0.32s (- 1.92%) |
16.13s |
16.24s |
p=0.005 n=6 |
| TFS - node (v16.17.1, x64) |
| Memory used |
299,646k (± 0.00%) |
299,372k (± 0.00%) |
-274k (- 0.09%) |
299,356k |
299,381k |
p=0.005 n=6 |
| Parse Time |
2.45s (± 1.08%) |
2.18s (± 0.73%) |
🟩-0.27s (-10.89%) |
2.15s |
2.19s |
p=0.004 n=6 |
| Bind Time |
1.26s (± 0.65%) |
1.26s (± 0.82%) |
~ |
1.24s |
1.27s |
p=0.932 n=6 |
| Check Time |
7.23s (± 0.43%) |
7.22s (± 0.45%) |
~ |
7.17s |
7.25s |
p=0.686 n=6 |
| Emit Time |
4.21s (± 0.47%) |
4.22s (± 1.08%) |
~ |
4.16s |
4.29s |
p=0.570 n=6 |
| Total Time |
15.14s (± 0.29%) |
14.88s (± 0.36%) |
-0.27s (- 1.76%) |
14.82s |
14.98s |
p=0.005 n=6 |
| material-ui - node (v16.17.1, x64) |
| Memory used |
475,972k (± 0.00%) |
475,695k (± 0.01%) |
-278k (- 0.06%) |
475,656k |
475,720k |
p=0.005 n=6 |
| Parse Time |
3.68s (± 0.24%) |
3.33s (± 0.52%) |
🟩-0.35s (- 9.56%) |
3.31s |
3.36s |
p=0.005 n=6 |
| Bind Time |
1.02s (± 0.62%) |
1.02s (± 0.00%) |
~ |
1.02s |
1.02s |
p=1.000 n=6 |
| Check Time |
18.31s (± 1.24%) |
18.21s (± 0.54%) |
~ |
18.11s |
18.34s |
p=0.572 n=6 |
| Emit Time |
0.00s (± 0.00%) |
0.00s (± 0.00%) |
~ |
0.00s |
0.00s |
p=1.000 n=6 |
| Total Time |
23.01s (± 0.97%) |
22.56s (± 0.49%) |
-0.45s (- 1.96%) |
22.46s |
22.69s |
p=0.005 n=6 |
| xstate - node (v16.17.1, x64) |
| Memory used |
546,950k (± 0.02%) |
546,050k (± 0.01%) |
-901k (- 0.16%) |
545,981k |
546,178k |
p=0.005 n=6 |
| Parse Time |
4.77s (± 0.54%) |
4.24s (± 0.23%) |
🟩-0.53s (-11.11%) |
4.23s |
4.26s |
p=0.004 n=6 |
| Bind Time |
1.85s (± 0.22%) |
1.80s (± 0.30%) |
-0.05s (- 2.52%) |
1.80s |
1.81s |
p=0.003 n=6 |
| Check Time |
3.07s (± 0.78%) |
3.08s (± 0.57%) |
~ |
3.05s |
3.10s |
p=0.870 n=6 |
| Emit Time |
0.09s (± 4.45%) |
0.09s (± 0.00%) |
~ |
0.09s |
0.09s |
p=0.405 n=6 |
| Total Time |
9.78s (± 0.45%) |
9.21s (± 0.26%) |
🟩-0.57s (- 5.84%) |
9.18s |
9.25s |
p=0.005 n=6 |
System
| Machine Name | ts-ci-ubuntu |
| Platform | linux 5.4.0-135-generic |
| Architecture | x64 |
| Available Memory | 16 GB |
| Available Memory | 15 GB |
| CPUs | 4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz |
Scenarios
- Angular - node (v16.17.1, x64)
- Compiler-Unions - node (v16.17.1, x64)
- Monaco - node (v16.17.1, x64)
- TFS - node (v16.17.1, x64)
- material-ui - node (v16.17.1, x64)
- xstate - node (v16.17.1, x64)
| Benchmark |
Name |
Iterations |
| Current |
52832 |
6 |
| Baseline |
main |
6 |
Developer Information:Download Benchmark
|
strager, zhangenming, zyhou, k-egor-smirnov, BasixKOR, and jakeisnt reacted with rocket emoji
strager and yhdgms1 reacted with eyes emoji
All reactions
-
🚀
6 reactions
-
👀
2 reactions
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Aside: is it just the scanner? Can we revert parser and test only the scanner? Is it a specific variable? That would be very interesting to know.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Feb 17, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
scanRange,
|
|
|
};
|
|
|
|
|
|
/* eslint-disable no-var */
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by - was this maybe supposed to be eslint-enable? It's already disabled above, and below there's no new vars.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
DanielRosenwasser, SlurpTheo, and ExE-Boss reacted with thumbs up emoji
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
+1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|