Skip to content

Clear out checker-level stacks on pop #62016

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jakebailey
Copy link
Member

These global-ish stacks left their references behind on pop. If the contents are ephemeral (sometimes happens with types, mappers), they'll be held indefinitely.

See also:

@Copilot Copilot AI review requested due to automatic review settings July 7, 2025 22:33
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Jul 7, 2025
@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Jul 7, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that stack-based contextual types, inference contexts, and active mapper caches are explicitly cleared when popping to avoid holding onto stale references and potential memory leaks.

  • Clear references in popContextualType and popInferenceContext
  • Adjust pushActiveMapper to reuse existing cache maps with ??=
  • Clear mapper entries and cache contents in popActiveMapper
Comments suppressed due to low confidence (2)

@jakebailey
Copy link
Member Author

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 7, 2025

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started ✅ Results
run dt ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results

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

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user tests with tsc comparing main and refs/pull/62016/merge:

Everything looks good!

Copy link
Member

@RyanCavanaugh RyanCavanaugh left a comment

Choose a reason for hiding this comment

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

LGTM. I like to use undefined! in these situations but as any is just as good.

@github-project-automation github-project-automation bot moved this from Not started to Needs merge in PR Backlog Jul 7, 2025
@jakebailey
Copy link
Member Author

Oh, oops, that's the incantation I meant to use.

@jakebailey
Copy link
Member Author

Need a re-review now, sorry; I definitely meant undefined! but forgot that spelling.

@jakebailey jakebailey enabled auto-merge (squash) July 7, 2025 23:17
@typescript-bot
Copy link
Collaborator

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

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - node (v18.15.0, x64)
Errors 34 34 ~ ~ ~ p=1.000 n=6
Symbols 62,370 62,370 ~ ~ ~ p=1.000 n=6
Types 50,386 50,386 ~ ~ ~ p=1.000 n=6
Memory used 195,399k (± 0.90%) 194,163k (± 0.99%) ~ 192,908k 196,693k p=0.470 n=6
Parse Time 1.30s (± 0.79%) 1.31s (± 0.48%) ~ 1.30s 1.32s p=0.293 n=6
Bind Time 0.73s 0.73s ~ ~ ~ p=1.000 n=6
Check Time 9.72s (± 0.36%) 9.71s (± 0.17%) ~ 9.68s 9.73s p=0.746 n=6
Emit Time 2.73s (± 0.38%) 2.76s (± 1.16%) ~ 2.72s 2.81s p=0.217 n=6
Total Time 14.49s (± 0.20%) 14.50s (± 0.27%) ~ 14.44s 14.55s p=0.518 n=6
angular-1 - node (v18.15.0, x64)
Errors 57 57 ~ ~ ~ p=1.000 n=6
Symbols 948,912 948,912 ~ ~ ~ p=1.000 n=6
Types 410,889 410,889 ~ ~ ~ p=1.000 n=6
Memory used 1,226,319k (± 0.00%) 1,226,397k (± 0.01%) +78k (+ 0.01%) 1,226,304k 1,226,482k p=0.045 n=6
Parse Time 6.50s (± 0.53%) 6.52s (± 0.84%) ~ 6.47s 6.62s p=0.806 n=6
Bind Time 1.87s (± 0.22%) 1.88s (± 0.29%) ~ 1.87s 1.88s p=0.282 n=6
Check Time 31.94s (± 0.51%) 32.01s (± 0.37%) ~ 31.83s 32.16s p=0.423 n=6
Emit Time 14.86s (± 0.63%) 14.85s (± 0.56%) ~ 14.72s 14.93s p=0.630 n=6
Total Time 55.18s (± 0.36%) 55.25s (± 0.21%) ~ 55.12s 55.38s p=0.520 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,510,641 2,510,641 ~ ~ ~ p=1.000 n=6
Types 892,802 892,802 ~ ~ ~ p=1.000 n=6
Memory used 2,805,949k (± 0.00%) 2,805,913k (± 0.00%) ~ 2,805,852k 2,805,938k p=0.093 n=6
Parse Time 10.51s (± 0.13%) 10.50s (± 0.55%) ~ 10.42s 10.60s p=0.677 n=6
Bind Time 2.74s (± 0.91%) 2.74s (± 0.79%) ~ 2.71s 2.77s p=1.000 n=6
Check Time 101.50s (± 0.91%) 102.09s (± 1.52%) ~ 101.00s 104.85s p=0.810 n=6
Emit Time 0.36s (± 1.50%) 0.37s (± 2.96%) ~ 0.35s 0.38s p=0.227 n=6
Total Time 115.11s (± 0.81%) 115.70s (± 1.34%) ~ 114.51s 118.45s p=0.936 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,227,048 1,227,048 ~ ~ ~ p=1.000 n=6
Types 267,470 267,470 ~ ~ ~ p=1.000 n=6
Memory used 2,852,890k (±13.23%) 2,609,622k (±14.46%) ~ 2,365,239k 3,097,490k p=0.936 n=6
Parse Time 6.63s (± 1.87%) 6.58s (± 1.24%) ~ 6.49s 6.70s p=0.423 n=6
Bind Time 2.17s (± 0.50%) 2.16s (± 1.51%) ~ 2.11s 2.20s p=1.000 n=6
Check Time 42.91s (± 0.41%) 42.81s (± 0.48%) ~ 42.51s 43.03s p=0.471 n=6
Emit Time 3.51s (± 2.82%) 3.50s (± 4.94%) ~ 3.34s 3.77s p=0.575 n=6
Total Time 55.21s (± 0.33%) 55.05s (± 0.48%) ~ 54.61s 55.36s p=0.378 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,227,048 1,227,048 ~ ~ ~ p=1.000 n=6
Types 267,470 267,470 ~ ~ ~ p=1.000 n=6
Memory used 2,430,230k (± 0.01%) 2,491,281k (± 5.96%) ~ 2,429,911k 2,794,523k p=0.173 n=6
Parse Time 5.42s (± 1.05%) 5.41s (± 0.87%) ~ 5.34s 5.48s p=0.575 n=6
Bind Time 1.82s (± 1.12%) 1.83s (± 0.75%) ~ 1.81s 1.84s p=0.566 n=6
Check Time 35.27s (± 0.34%) 35.33s (± 0.47%) ~ 35.03s 35.46s p=0.378 n=6
Emit Time 3.03s (± 1.30%) 3.08s (± 3.86%) ~ 2.97s 3.31s p=0.748 n=6
Total Time 45.56s (± 0.28%) 45.64s (± 0.52%) ~ 45.34s 45.93s p=0.378 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 262,548 262,548 ~ ~ ~ p=1.000 n=6
Types 107,156 107,156 ~ ~ ~ p=1.000 n=6
Memory used 441,714k (± 0.01%) 441,760k (± 0.01%) ~ 441,722k 441,853k p=0.128 n=6
Parse Time 2.91s (± 0.55%) 2.90s (± 0.36%) ~ 2.89s 2.92s p=0.615 n=6
Bind Time 1.11s 1.11s ~ ~ ~ p=1.000 n=6
Check Time 15.79s (± 0.29%) 15.83s (± 0.30%) ~ 15.77s 15.91s p=0.147 n=6
Emit Time 1.31s (± 1.22%) 1.30s (± 1.94%) ~ 1.25s 1.32s p=0.739 n=6
Total Time 21.12s (± 0.26%) 21.15s (± 0.26%) ~ 21.09s 21.25s p=0.627 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 71 71 ~ ~ ~ p=1.000 n=6
Symbols 225,367 225,367 ~ ~ ~ p=1.000 n=6
Types 94,290 94,290 ~ ~ ~ p=1.000 n=6
Memory used 371,173k (± 0.04%) 371,107k (± 0.01%) ~ 371,040k 371,170k p=0.471 n=6
Parse Time 2.89s (± 0.99%) 2.88s (± 1.15%) ~ 2.82s 2.91s p=0.462 n=6
Bind Time 1.60s (± 1.74%) 1.58s (± 0.65%) ~ 1.57s 1.60s p=0.287 n=6
Check Time 16.38s (± 0.18%) 16.47s (± 0.31%) +0.09s (+ 0.53%) 16.42s 16.55s p=0.006 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 20.88s (± 0.28%) 20.93s (± 0.28%) ~ 20.83s 20.99s p=0.227 n=6
vscode - node (v18.15.0, x64)
Errors 33 33 ~ ~ ~ p=1.000 n=6
Symbols 3,514,764 3,514,764 ~ ~ ~ p=1.000 n=6
Types 1,181,724 1,181,724 ~ ~ ~ p=1.000 n=6
Memory used 3,562,892k (± 0.01%) 3,562,912k (± 0.01%) ~ 3,562,599k 3,563,249k p=0.936 n=6
Parse Time 15.15s (± 0.41%) 15.13s (± 0.56%) ~ 14.99s 15.21s p=0.688 n=6
Bind Time 4.92s (± 0.95%) 4.92s (± 0.39%) ~ 4.90s 4.95s p=0.871 n=6
Check Time 97.65s (± 3.96%) 99.77s (± 1.59%) ~ 97.69s 102.36s p=0.689 n=6
Emit Time 33.66s (± 7.95%) 33.20s (± 8.95%) ~ 31.14s 37.32s p=0.810 n=6
Total Time 151.38s (± 2.53%) 153.02s (± 2.27%) ~ 150.06s 159.15s p=0.575 n=6
webpack - node (v18.15.0, x64)
Errors 2 2 ~ ~ ~ p=1.000 n=6
Symbols 318,635 318,635 ~ ~ ~ p=1.000 n=6
Types 137,786 137,786 ~ ~ ~ p=1.000 n=6
Memory used 474,114k (± 0.02%) 474,143k (± 0.03%) ~ 473,978k 474,333k p=0.810 n=6
Parse Time 5.32s (± 0.51%) 5.30s (± 0.66%) ~ 5.26s 5.35s p=0.259 n=6
Bind Time 2.22s (± 0.83%) 2.23s (± 0.88%) ~ 2.21s 2.26s p=0.807 n=6
Check Time 25.57s (± 0.33%) 25.57s (± 0.46%) ~ 25.45s 25.73s p=1.000 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 33.11s (± 0.30%) 33.10s (± 0.33%) ~ 32.95s 33.24s p=1.000 n=6
xstate-main - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 666,092 666,092 ~ ~ ~ p=1.000 n=6
Types 199,363 199,363 ~ ~ ~ p=1.000 n=6
Memory used 571,434k (± 0.04%) 571,545k (± 0.02%) ~ 571,364k 571,623k p=0.378 n=6
Parse Time 4.27s (± 0.48%) 4.26s (± 0.71%) ~ 4.21s 4.28s p=0.743 n=6
Bind Time 1.32s (± 1.48%) 1.33s (± 0.78%) ~ 1.31s 1.34s p=0.406 n=6
Check Time 19.93s (± 0.71%) 20.10s (± 1.31%) ~ 19.96s 20.63s p=0.199 n=6
Emit Time 0.00s (±244.70%) 0.00s ~ ~ ~ p=0.405 n=6
Total Time 25.53s (± 0.55%) 25.68s (± 1.08%) ~ 25.50s 26.24s p=0.378 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - 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 top 400 repos with tsc comparing main and refs/pull/62016/merge:

Everything looks good!

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
Status: Needs merge
Development

Successfully merging this pull request may close these issues.

3 participants