Skip to content

Avoid quadratic trackSymbol explosion from new trackedSymbols #56404

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

Closed
wants to merge 4 commits into from

Conversation

jakebailey
Copy link
Member

#51721 added a new trackedSymbols prop to serialized types, which when seen is used to pull tracked symbols from one context into another. But, if you look up a symbol in the same context, you'll keep pushing symbols onto yourself over and over when they're already tracked. So, if we see that the list is exactly the same, don't actually iterate over it.

Fixes #56371

@jakebailey
Copy link
Member Author

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

@typescript-bot perf test this
@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 15, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 15, 2023

Heya @jakebailey, I've started to run the diff-based user code test suite on this PR at 7aeb7d8. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 15, 2023

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 15, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 15, 2023

Heya @jakebailey, I've started to run the diff-based top-repos suite on this PR at 7aeb7d8. You can monitor the build here.

Update: The results are in!

@jakebailey
Copy link
Member Author

@JoshuaKGoldberg there should be a tarball for you to test out in a bit.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 15, 2023

Hey @jakebailey, 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/158596/artifacts?artifactName=tgz&fileId=BF7A4365719710A8AF87A468275F0B7CD2285D8A00DBF5463A8ACB7D5897723D02&fileName=/typescript-5.4.0-insiders.20231115.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/[email protected]".;

Copy link
Member

@sheetalkamat sheetalkamat left a comment

Choose a reason for hiding this comment

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

This seems correct but do we have a test case to add..

@typescript-bot
Copy link
Collaborator

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

Here they are:

Compiler

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Angular - node (v18.15.0, x64)
Memory used 295,166k (± 0.02%) 295,175k (± 0.01%) ~ 295,110k 295,224k p=0.810 n=6
Parse Time 2.63s (± 0.21%) 2.64s (± 0.39%) ~ 2.63s 2.66s p=0.138 n=6
Bind Time 0.82s (± 0.99%) 0.83s (± 0.91%) ~ 0.82s 0.84s p=0.206 n=6
Check Time 8.04s (± 0.32%) 8.03s (± 0.51%) ~ 7.97s 8.07s p=0.809 n=6
Emit Time 7.10s (± 0.35%) 7.08s (± 0.33%) ~ 7.05s 7.11s p=0.090 n=6
Total Time 18.59s (± 0.14%) 18.57s (± 0.25%) ~ 18.50s 18.63s p=0.687 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 191,648k (± 1.23%) 194,023k (± 1.48%) ~ 190,666k 196,521k p=0.173 n=6
Parse Time 1.35s (± 1.01%) 1.34s (± 0.77%) ~ 1.33s 1.35s p=0.293 n=6
Bind Time 0.72s (± 0.00%) 0.72s (± 0.00%) ~ 0.72s 0.72s p=1.000 n=6
Check Time 9.14s (± 0.53%) 9.14s (± 0.36%) ~ 9.10s 9.19s p=1.000 n=6
Emit Time 2.62s (± 0.86%) 2.63s (± 0.56%) ~ 2.61s 2.65s p=0.515 n=6
Total Time 13.84s (± 0.39%) 13.83s (± 0.27%) ~ 13.78s 13.88s p=0.748 n=6
Monaco - node (v18.15.0, x64)
Memory used 347,331k (± 0.00%) 347,345k (± 0.01%) ~ 347,315k 347,378k p=0.378 n=6
Parse Time 2.46s (± 0.26%) 2.45s (± 0.52%) ~ 2.43s 2.46s p=0.152 n=6
Bind Time 0.93s (± 0.44%) 0.92s (± 0.59%) ~ 0.92s 0.93s p=0.282 n=6
Check Time 6.92s (± 0.72%) 6.93s (± 0.30%) ~ 6.90s 6.96s p=0.936 n=6
Emit Time 4.05s (± 0.41%) 4.04s (± 0.33%) ~ 4.02s 4.06s p=0.249 n=6
Total Time 14.36s (± 0.36%) 14.34s (± 0.20%) ~ 14.31s 14.38s p=0.573 n=6
TFS - node (v18.15.0, x64)
Memory used 302,626k (± 0.00%) 302,623k (± 0.01%) ~ 302,605k 302,642k p=0.748 n=6
Parse Time 2.00s (± 1.07%) 2.00s (± 0.86%) ~ 1.98s 2.02s p=1.000 n=6
Bind Time 1.00s (± 0.82%) 1.01s (± 1.22%) ~ 0.99s 1.02s p=0.235 n=6
Check Time 6.26s (± 0.46%) 6.26s (± 0.20%) ~ 6.25s 6.28s p=0.935 n=6
Emit Time 3.57s (± 0.34%) 3.58s (± 0.70%) ~ 3.56s 3.63s p=0.623 n=6
Total Time 12.83s (± 0.19%) 12.85s (± 0.20%) ~ 12.82s 12.89s p=0.167 n=6
material-ui - node (v18.15.0, x64)
Memory used 470,586k (± 0.00%) 470,561k (± 0.01%) ~ 470,510k 470,603k p=0.336 n=6
Parse Time 2.57s (± 0.43%) 2.57s (± 0.60%) ~ 2.55s 2.59s p=1.000 n=6
Bind Time 0.99s (± 0.90%) 0.99s (± 1.43%) ~ 0.97s 1.01s p=1.000 n=6
Check Time 16.63s (± 0.48%) 16.62s (± 0.29%) ~ 16.57s 16.71s p=0.810 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.19s (± 0.48%) 20.18s (± 0.30%) ~ 20.11s 20.29s p=0.810 n=6
xstate - node (v18.15.0, x64)
Memory used 512,831k (± 0.01%) 512,884k (± 0.01%) ~ 512,817k 512,947k p=0.092 n=6
Parse Time 3.27s (± 0.19%) 3.28s (± 0.32%) ~ 3.26s 3.29s p=0.388 n=6
Bind Time 1.54s (± 0.64%) 1.54s (± 0.89%) ~ 1.51s 1.55s p=0.924 n=6
Check Time 2.86s (± 0.57%) 2.87s (± 0.51%) ~ 2.85s 2.89s p=0.368 n=6
Emit Time 0.08s (± 0.00%) 0.08s (± 0.00%) ~ 0.08s 0.08s p=1.000 n=6
Total Time 7.75s (± 0.19%) 7.77s (± 0.32%) ~ 7.72s 7.79s p=0.119 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - node (v18.15.0, x64)
  • xstate - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

tsserver

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-UnionsTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,351ms (± 1.06%) 2,361ms (± 0.67%) ~ 2,340ms 2,382ms p=0.378 n=6
Req 2 - geterr 5,393ms (± 1.39%) 5,412ms (± 1.39%) ~ 5,306ms 5,469ms p=0.873 n=6
Req 3 - references 326ms (± 0.96%) 325ms (± 0.77%) ~ 321ms 328ms p=0.806 n=6
Req 4 - navto 277ms (± 1.06%) 275ms (± 1.22%) ~ 273ms 280ms p=0.185 n=6
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) ~ 1,356 1,356 p=1.000 n=6
Req 5 - completionInfo 86ms (± 6.22%) 85ms (± 7.09%) ~ 75ms 90ms p=0.805 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,503ms (± 0.90%) 2,476ms (± 0.94%) ~ 2,442ms 2,511ms p=0.066 n=6
Req 2 - geterr 4,105ms (± 1.92%) 4,078ms (± 1.90%) ~ 4,016ms 4,190ms p=0.521 n=6
Req 3 - references 337ms (± 1.62%) 340ms (± 1.98%) ~ 331ms 346ms p=0.418 n=6
Req 4 - navto 283ms (± 0.72%) 283ms (± 0.65%) ~ 280ms 285ms p=1.000 n=6
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) ~ 1,518 1,518 p=1.000 n=6
Req 5 - completionInfo 82ms (± 7.74%) 84ms (± 7.41%) ~ 78ms 90ms p=0.446 n=6
xstateTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,595ms (± 0.63%) 2,599ms (± 0.59%) ~ 2,573ms 2,614ms p=0.630 n=6
Req 2 - geterr 1,702ms (± 2.16%) 1,685ms (± 2.49%) ~ 1,663ms 1,770ms p=0.298 n=6
Req 3 - references 106ms (± 8.12%) 116ms (± 8.68%) 🔻+10ms (+ 9.48%) 103ms 125ms p=0.030 n=6
Req 4 - navto 367ms (± 0.40%) 368ms (± 0.56%) ~ 364ms 370ms p=0.405 n=6
Req 5 - completionInfo count 2,073 (± 0.00%) 2,073 (± 0.00%) ~ 2,073 2,073 p=1.000 n=6
Req 5 - completionInfo 307ms (± 2.15%) 306ms (± 2.06%) ~ 300ms 317ms p=0.747 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • CompilerTSServer - node (v18.15.0, x64)
  • Compiler-UnionsTSServer - node (v18.15.0, x64)
  • xstateTSServer - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Startup

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
tsc-startup - node (v18.15.0, x64)
Execution time 152.67ms (± 0.16%) 152.54ms (± 0.17%) -0.13ms (- 0.08%) 151.60ms 155.19ms p=0.000 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time 227.37ms (± 0.15%) 227.29ms (± 0.18%) -0.07ms (- 0.03%) 226.14ms 236.63ms p=0.002 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time 229.23ms (± 0.17%) 229.25ms (± 0.18%) ~ 227.50ms 237.39ms p=0.854 n=600
typescript-startup - node (v18.15.0, x64)
Execution time 229.05ms (± 0.15%) 229.05ms (± 0.15%) ~ 227.64ms 232.43ms p=0.786 n=600
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • tsc-startup - node (v18.15.0, x64)
  • tsserver-startup - node (v18.15.0, x64)
  • tsserverlibrary-startup - node (v18.15.0, x64)
  • typescript-startup - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user test suite comparing main and refs/pull/56404/merge:

There were infrastructure failures potentially unrelated to your change:

  • 2 instances of "Package install failed"

Otherwise...

Something interesting changed - please have a look.

Details

puppeteer

packages/browsers/test/src/tsconfig.json

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.
Everything looks the same!
You can check the log here.

@JoshuaKGoldberg
Copy link
Contributor

Confirmed this fixes it for us, thanks so much @jakebailey!

Btw as a heads up for anybody else trying on typescript-eslint / typescript-eslint/typescript-eslint#7923, switching to "resolutions" > "typescript": "npm:@typescript-deploys/[email protected]" gives the following error in Yarn unless you rm -rf node_modules:

joshgoldberg ~/repos/typescript-eslint $ yarn
➤ YN0000: ┌ Project validation
➤ YN0057: │ website: Resolutions field will be ignored
➤ YN0000: └ Completed
➤ YN0000: ┌ Resolution step
➤ YN0001: │ RequestError: Socket connection timeout
    at ClientRequest.<anonymous> (/Users/josh/repos/typescript-eslint/.yarn/releases/yarn-3.6.4.cjs:195:14340)
    at Object.onceWrapper (node:events:626:26)
    at ClientRequest.emit (node:events:523:35)
    at o.emit (/Users/josh/repos/typescript-eslint/.yarn/releases/yarn-3.6.4.cjs:190:90286)
    at TLSSocket.socketErrorListener (node:_http_client:495:9)
    at TLSSocket.emit (node:events:511:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
    at new NodeError (node:internal/errors:399:5)
    at internalConnectMultiple (node:net:1099:20)
    at Timeout.internalConnectMultipleTimeout (node:net:1638:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
➤ YN0000: └ Completed in 3s 169ms
➤ YN0000: Failed with errors in 3s 173ms

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top-repos suite comparing main and refs/pull/56404/merge:

Everything looks good!

@jakebailey
Copy link
Member Author

Thanks for confirming. I'll need to try and figure out some sort of minimal repro for this... Which I don't expect to be easy.

@jakebailey jakebailey closed this Nov 17, 2023
@jakebailey jakebailey deleted the fix-51721 branch November 17, 2023 12:18
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
None yet
Development

Successfully merging this pull request may close these issues.

Heap out of memory in 5.3.1-rc but not 5.3.0-beta
4 participants