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

Fix binder performance regression #31142

Merged
merged 1 commit into from Apr 29, 2019
Merged

Fix binder performance regression #31142

merged 1 commit into from Apr 29, 2019

Conversation

rbuckton
Copy link
Member

When we introduced globalThis support, we inadvertently regressed binder performance by over 100%. This regression appears to be due to an early change to the shape of our Symbol type prior to binder being called.

@rbuckton
Copy link
Member Author

@typescript-bot perf test

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 28, 2019

Heya @rbuckton, I've started to run the perf test suite on this PR at 57a8ee1. You can monitor the build here. It should now contribute to this PR's status checks.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..31142

Metric master 31142 Delta Best Worst
Angular - node (v6.5.0, x64)
Memory used 341,098k (± 0.43%) 343,111k (± 0.02%) +2,013k (+ 0.59%) 342,936k 343,198k
Parse Time 1.63s (± 1.36%) 1.60s (± 1.72%) -0.03s (- 1.78%) 1.53s 1.64s
Bind Time 1.56s (± 2.01%) 0.89s (± 4.49%) -0.67s (-43.12%) 0.83s 0.99s
Check Time 4.89s (± 0.54%) 4.84s (± 0.50%) -0.04s (- 0.90%) 4.80s 4.92s
Emit Time 6.39s (± 1.81%) 7.85s (± 0.82%) +1.46s (+22.86%) 7.69s 8.02s
Total Time 14.46s (± 0.97%) 15.18s (± 0.52%) +0.71s (+ 4.93%) 15.01s 15.35s
Monaco - node (v6.5.0, x64)
Memory used 364,439k (± 0.08%) 367,302k (± 0.09%) +2,863k (+ 0.79%) 367,006k 368,623k
Parse Time 1.27s (± 0.84%) 1.27s (± 0.45%) +0.00s (+ 0.32%) 1.26s 1.28s
Bind Time 1.52s (± 0.66%) 0.75s (± 0.87%) -0.78s (-50.95%) 0.73s 0.76s
Check Time 5.82s (± 0.92%) 5.77s (± 0.57%) -0.06s (- 0.96%) 5.71s 5.83s
Emit Time 3.65s (± 2.11%) 5.19s (± 1.18%) +1.54s (+42.17%) 5.03s 5.33s
Total Time 12.27s (± 0.87%) 12.98s (± 0.66%) +0.71s (+ 5.79%) 12.77s 13.19s
TFS - node (v6.5.0, x64)
Memory used 321,072k (± 0.02%) 322,702k (± 0.01%) +1,630k (+ 0.51%) 322,646k 322,788k
Parse Time 0.98s (± 0.48%) 0.98s (± 0.35%) -0.00s (- 0.31%) 0.97s 0.98s
Bind Time 1.27s (± 0.80%) 0.63s (± 1.30%) -0.63s (-49.88%) 0.62s 0.66s
Check Time 4.41s (± 0.38%) 4.38s (± 0.57%) -0.03s (- 0.70%) 4.33s 4.42s
Emit Time 3.14s (± 0.77%) 4.37s (± 0.72%) +1.23s (+39.15%) 4.30s 4.44s
Total Time 9.80s (± 0.32%) 10.36s (± 0.47%) +0.56s (+ 5.74%) 10.27s 10.46s
Angular - node (v6.5.0, x86)
Memory used 191,048k (± 0.01%) 191,654k (± 0.02%) +606k (+ 0.32%) 191,569k 191,688k
Parse Time 1.47s (± 0.98%) 1.46s (± 0.97%) -0.01s (- 0.41%) 1.44s 1.50s
Bind Time 1.52s (± 1.10%) 0.72s (± 0.82%) -0.79s (-52.24%) 0.71s 0.74s
Check Time 4.81s (± 2.12%) 4.74s (± 1.34%) -0.07s (- 1.48%) 4.64s 4.96s
Emit Time 6.12s (± 1.59%) 6.03s (± 1.67%) -0.08s (- 1.39%) 5.81s 6.36s
Total Time 13.91s (± 1.34%) 12.96s (± 1.23%) -0.95s (- 6.85%) 12.65s 13.49s
Monaco - node (v6.5.0, x86)
Memory used 204,369k (± 0.00%) 204,819k (± 0.01%) +450k (+ 0.22%) 204,759k 204,849k
Parse Time 1.27s (± 0.76%) 1.27s (± 0.84%) -0.00s (- 0.32%) 1.25s 1.29s
Bind Time 1.55s (± 0.71%) 0.68s (± 0.70%) -0.87s (-55.88%) 0.67s 0.69s
Check Time 4.65s (± 0.30%) 4.57s (± 0.69%) -0.08s (- 1.68%) 4.52s 4.65s
Emit Time 3.22s (± 0.58%) 3.23s (± 1.13%) +0.01s (+ 0.44%) 3.10s 3.28s
Total Time 10.68s (± 0.17%) 9.75s (± 0.54%) -0.94s (- 8.77%) 9.65s 9.89s
TFS - node (v6.5.0, x86)
Memory used 180,376k (± 0.01%) 180,806k (± 0.01%) +430k (+ 0.24%) 180,779k 180,834k
Parse Time 0.98s (± 0.83%) 0.98s (± 0.70%) +0.00s (+ 0.51%) 0.97s 1.00s
Bind Time 1.30s (± 0.90%) 0.59s (± 1.05%) -0.71s (-54.55%) 0.58s 0.60s
Check Time 3.90s (± 0.66%) 3.93s (± 0.57%) +0.02s (+ 0.61%) 3.88s 3.97s
Emit Time 2.56s (± 0.89%) 2.60s (± 1.17%) +0.04s (+ 1.64%) 2.54s 2.67s
Total Time 8.74s (± 0.39%) 8.10s (± 0.59%) -0.64s (- 7.32%) 8.02s 8.24s
Angular - node (v8.9.0, x64)
Memory used 330,715k (± 0.01%) 330,895k (± 0.01%) +181k (+ 0.05%) 330,782k 330,978k
Parse Time 1.81s (± 0.64%) 1.79s (± 0.39%) -0.01s (- 0.78%) 1.77s 1.80s
Bind Time 1.37s (± 1.13%) 0.79s (± 0.56%) -0.58s (-42.27%) 0.78s 0.80s
Check Time 4.61s (± 1.11%) 4.66s (± 1.49%) +0.06s (+ 1.22%) 4.52s 4.78s
Emit Time 5.94s (± 2.68%) 5.83s (± 3.07%) -0.11s (- 1.93%) 5.49s 6.18s
Total Time 13.73s (± 0.85%) 13.07s (± 1.12%) -0.65s (- 4.75%) 12.76s 13.36s
Monaco - node (v8.9.0, x64)
Memory used 358,485k (± 0.02%) 358,642k (± 0.01%) +157k (+ 0.04%) 358,534k 358,751k
Parse Time 1.45s (± 0.72%) 1.45s (± 0.61%) -0.01s (- 0.41%) 1.44s 1.48s
Bind Time 1.53s (± 0.76%) 0.89s (± 1.50%) -0.63s (-41.45%) 0.86s 0.93s
Check Time 4.82s (± 1.57%) 4.81s (± 1.53%) -0.01s (- 0.25%) 4.74s 5.05s
Emit Time 3.16s (± 5.18%) 3.28s (± 5.34%) +0.12s (+ 3.74%) 2.80s 3.48s
Total Time 10.96s (± 0.99%) 10.43s (± 1.13%) -0.53s (- 4.85%) 10.06s 10.60s
TFS - node (v8.9.0, x64)
Memory used 313,860k (± 0.02%) 314,030k (± 0.01%) +170k (+ 0.05%) 313,972k 314,109k
Parse Time 1.14s (± 0.42%) 1.14s (± 0.41%) -0.00s (- 0.26%) 1.13s 1.15s
Bind Time 1.24s (± 0.77%) 0.66s (± 0.87%) -0.57s (-46.36%) 0.65s 0.68s
Check Time 4.22s (± 0.53%) 4.21s (± 0.52%) -0.01s (- 0.26%) 4.15s 4.26s
Emit Time 3.11s (± 1.23%) 3.12s (± 1.28%) +0.00s (+ 0.10%) 2.98s 3.17s
Total Time 9.71s (± 0.46%) 9.13s (± 0.47%) -0.58s (- 6.00%) 9.03s 9.21s
Angular - node (v8.9.0, x86)
Memory used 187,179k (± 0.02%) 187,352k (± 0.04%) +173k (+ 0.09%) 187,258k 187,617k
Parse Time 1.75s (± 0.78%) 1.75s (± 0.58%) +0.00s (+ 0.11%) 1.74s 1.78s
Bind Time 1.53s (± 0.85%) 0.92s (± 1.73%) -0.61s (-39.83%) 0.88s 0.95s
Check Time 4.29s (± 0.80%) 4.31s (± 0.53%) +0.02s (+ 0.49%) 4.26s 4.37s
Emit Time 5.66s (± 0.80%) 5.67s (± 0.98%) +0.00s (+ 0.05%) 5.56s 5.77s
Total Time 13.23s (± 0.51%) 12.64s (± 0.63%) -0.59s (- 4.44%) 12.50s 12.79s
Monaco - node (v8.9.0, x86)
Memory used 199,844k (± 0.02%) 200,034k (± 0.01%) +189k (+ 0.09%) 199,993k 200,072k
Parse Time 1.50s (± 0.77%) 1.51s (± 0.64%) +0.00s (+ 0.33%) 1.49s 1.54s
Bind Time 1.39s (± 0.65%) 0.72s (± 1.21%) -0.67s (-48.31%) 0.71s 0.75s
Check Time 4.58s (± 0.40%) 4.61s (± 0.42%) +0.03s (+ 0.63%) 4.57s 4.65s
Emit Time 3.09s (± 0.56%) 3.10s (± 0.65%) +0.00s (+ 0.13%) 3.05s 3.14s
Total Time 10.57s (± 0.31%) 9.94s (± 0.39%) -0.63s (- 5.95%) 9.82s 10.00s
TFS - node (v8.9.0, x86)
Memory used 175,899k (± 0.02%) 176,090k (± 0.03%) +191k (+ 0.11%) 176,024k 176,248k
Parse Time 1.20s (± 0.92%) 1.21s (± 1.08%) +0.01s (+ 0.50%) 1.19s 1.25s
Bind Time 1.23s (± 0.74%) 0.63s (± 0.94%) -0.60s (-48.50%) 0.62s 0.65s
Check Time 4.03s (± 0.38%) 4.03s (± 0.59%) +0.00s (+ 0.12%) 3.97s 4.09s
Emit Time 2.79s (± 1.13%) 2.77s (± 0.70%) -0.02s (- 0.75%) 2.74s 2.82s
Total Time 9.26s (± 0.44%) 8.65s (± 0.45%) -0.61s (- 6.59%) 8.56s 8.75s
Angular - node (v9.0.0, x64)
Memory used 330,498k (± 0.03%) 330,542k (± 0.02%) +44k (+ 0.01%) 330,356k 330,635k
Parse Time 1.64s (± 0.46%) 1.64s (± 0.38%) +0.00s (+ 0.18%) 1.62s 1.65s
Bind Time 1.34s (± 0.68%) 0.74s (± 0.91%) -0.59s (-44.44%) 0.73s 0.76s
Check Time 4.37s (± 1.42%) 4.33s (± 0.41%) -0.04s (- 0.98%) 4.29s 4.37s
Emit Time 5.76s (± 2.20%) 5.70s (± 1.73%) -0.06s (- 1.01%) 5.58s 5.91s
Total Time 13.11s (± 0.96%) 12.41s (± 0.81%) -0.69s (- 5.29%) 12.27s 12.65s
Monaco - node (v9.0.0, x64)
Memory used 358,253k (± 0.01%) 358,541k (± 0.02%) +287k (+ 0.08%) 358,384k 358,800k
Parse Time 1.29s (± 0.69%) 1.29s (± 0.46%) 0.00s ( 0.00%) 1.29s 1.31s
Bind Time 1.51s (± 0.58%) 0.84s (± 0.89%) -0.67s (-44.17%) 0.83s 0.87s
Check Time 4.70s (± 0.49%) 4.68s (± 0.28%) -0.02s (- 0.36%) 4.66s 4.71s
Emit Time 3.22s (± 0.36%) 3.28s (± 0.47%) +0.06s (+ 1.99%) 3.25s 3.31s
Total Time 10.72s (± 0.25%) 10.10s (± 0.20%) -0.62s (- 5.81%) 10.05s 10.13s
TFS - node (v9.0.0, x64)
Memory used 313,790k (± 0.01%) 313,934k (± 0.02%) +144k (+ 0.05%) 313,815k 314,024k
Parse Time 1.01s (± 0.57%) 1.02s (± 0.55%) +0.00s (+ 0.49%) 1.01s 1.03s
Bind Time 1.21s (± 1.33%) 0.61s (± 0.78%) -0.60s (-49.38%) 0.61s 0.63s
Check Time 4.28s (± 1.78%) 4.15s (± 1.36%) -0.12s (- 2.88%) 4.10s 4.37s
Emit Time 2.96s (± 2.89%) 3.06s (± 2.30%) +0.10s (+ 3.42%) 2.82s 3.15s
Total Time 9.46s (± 0.52%) 8.84s (± 0.50%) -0.61s (- 6.47%) 8.70s 8.90s
Angular - node (v9.0.0, x86)
Memory used 187,390k (± 0.03%) 187,519k (± 0.03%) +129k (+ 0.07%) 187,427k 187,697k
Parse Time 1.57s (± 0.71%) 1.56s (± 0.72%) -0.01s (- 0.45%) 1.53s 1.59s
Bind Time 1.51s (± 0.55%) 0.88s (± 0.68%) -0.64s (-42.14%) 0.86s 0.89s
Check Time 4.05s (± 0.89%) 4.03s (± 0.68%) -0.02s (- 0.54%) 3.96s 4.08s
Emit Time 5.34s (± 0.95%) 5.40s (± 0.98%) +0.07s (+ 1.22%) 5.29s 5.57s
Total Time 12.47s (± 0.66%) 11.87s (± 0.50%) -0.60s (- 4.80%) 11.74s 12.04s
Monaco - node (v9.0.0, x86)
Memory used 199,927k (± 0.02%) 200,065k (± 0.03%) +137k (+ 0.07%) 199,974k 200,223k
Parse Time 1.33s (± 0.79%) 1.33s (± 0.57%) -0.01s (- 0.53%) 1.31s 1.34s
Bind Time 1.37s (± 0.63%) 0.64s (± 1.06%) -0.72s (-52.92%) 0.63s 0.66s
Check Time 4.49s (± 0.51%) 4.49s (± 0.50%) +0.00s (+ 0.04%) 4.45s 4.55s
Emit Time 3.04s (± 0.55%) 3.01s (± 0.61%) -0.03s (- 1.15%) 2.97s 3.04s
Total Time 10.24s (± 0.27%) 9.47s (± 0.41%) -0.77s (- 7.49%) 9.39s 9.55s
TFS - node (v9.0.0, x86)
Memory used 176,038k (± 0.03%) 176,200k (± 0.02%) +162k (+ 0.09%) 176,144k 176,295k
Parse Time 1.04s (± 0.78%) 1.04s (± 0.47%) +0.00s (+ 0.38%) 1.03s 1.05s
Bind Time 1.22s (± 1.11%) 0.57s (± 1.43%) -0.65s (-52.99%) 0.56s 0.60s
Check Time 3.93s (± 0.53%) 3.90s (± 0.56%) -0.03s (- 0.86%) 3.85s 3.96s
Emit Time 2.70s (± 1.08%) 2.69s (± 1.00%) -0.01s (- 0.22%) 2.61s 2.74s
Total Time 8.89s (± 0.50%) 8.21s (± 0.47%) -0.68s (- 7.65%) 8.10s 8.30s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-142-generic
Architecturex64
Available Memory16 GB
Available Memory1 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v6.5.0, x64)
  • node (v6.5.0, x86)
  • node (v8.9.0, x64)
  • node (v8.9.0, x86)
  • node (v9.0.0, x64)
  • node (v9.0.0, x86)
Scenarios
  • Angular - node (v6.5.0, x64)
  • Angular - node (v6.5.0, x86)
  • Angular - node (v8.9.0, x64)
  • Angular - node (v8.9.0, x86)
  • Angular - node (v9.0.0, x64)
  • Angular - node (v9.0.0, x86)
  • Monaco - node (v6.5.0, x64)
  • Monaco - node (v6.5.0, x86)
  • Monaco - node (v8.9.0, x64)
  • Monaco - node (v8.9.0, x86)
  • Monaco - node (v9.0.0, x64)
  • Monaco - node (v9.0.0, x86)
  • TFS - node (v6.5.0, x64)
  • TFS - node (v6.5.0, x86)
  • TFS - node (v8.9.0, x64)
  • TFS - node (v8.9.0, x86)
  • TFS - node (v9.0.0, x64)
  • TFS - node (v9.0.0, x86)
Benchmark Name Iterations
Current 31142 10
Baseline master 10

@microsoft microsoft deleted a comment from typescript-bot Apr 28, 2019
@microsoft microsoft deleted a comment from typescript-bot Apr 28, 2019
@rbuckton
Copy link
Member Author

This change significantly improves bind time across the board. The emit time changes don't make much sense as far as I can tell, so I'm not certain if they are relevant. Nothing I changed should affect emit time, so it is likely some other deoptimization specific to Node 6.5.0 (x64), which I'm not sure we should care about since it exits LTS maintenance in 3 days on 4/30/2019.

@rbuckton rbuckton marked this pull request as ready for review April 28, 2019 06:12
@weswigham
Copy link
Member

Angular - node (v6.5.0, x64)/Emit Time was outside of the allowed range (22.86% worse than baseline).‌
Monaco - node (v6.5.0, x64)/Emit Time was outside of the allowed range (42.17% worse than baseline).
TFS - node (v6.5.0, x64)/Emit Time was outside of the allowed range (39.15% worse than baseline).

Wow. That's significant. Definitely some node 6 specific deopt.



==== tests/cases/conformance/es2019/globalThisCollision.js (1 errors) ====
var globalThis;
Copy link
Member

Choose a reason for hiding this comment

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

nitpit: an even better test would be var globalThis = window or var globalThis = this since that's the likely polyfill code we'll see in JS.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think its necessary since that doesn't effect the outcome of the test, this is purely testing that var globalThis in the global scope results in our collision error message.

@rbuckton rbuckton merged commit 7423c69 into master Apr 29, 2019
@rbuckton rbuckton deleted the binderPerf branch April 29, 2019 18:52
@andrewbranch
Copy link
Member

Was this a case of objects of the same type not sharing the same hidden class?

@rbuckton
Copy link
Member Author

rbuckton commented May 9, 2019

Effectively, yes. By setting some expando properties early on a Symbol, v8 chose a completely different set of operations to optimize. Deoptimization traces showed that we ended up with about 50% more eager deoptimizations due to wrong map in the binder in functions that were previously either optimized or inlined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants