Skip to content

Disable expression type caching in CFA for loops - #64018

Draft
Anders Hejlsberg (ahejlsberg) wants to merge 2 commits into
mainfrom
fix-64012
Draft

Disable expression type caching in CFA for loops#64018
Anders Hejlsberg (ahejlsberg) wants to merge 2 commits into
mainfrom
fix-64012

Conversation

@ahejlsberg

@ahejlsberg Anders Hejlsberg (ahejlsberg) commented Aug 25, 2026

Copy link
Copy Markdown
Member

This PR disables expression type caching during control flow analysis of loops. Previously, when resolving an expression type that we were going to cache, we'd first save off the flop loop caches in order to start expression type resolution from a known point. However, this could cause infinite recursion.

This PR supersedes #64013, which had the same effect but kept old redundant logic.

Fixes #64012.

@ahejlsberg

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) test it

@typescript-automation

typescript-automation Bot commented Aug 25, 2026

Copy link
Copy Markdown

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-automation

Copy link
Copy Markdown

Anders Hejlsberg (@ahejlsberg) Here are the results of running the user tests with tsc comparing main and refs/pull/64018/merge:

There were infrastructure failures potentially unrelated to your change:

  • 2 instances of "Package install failed"
  • 1 instance of "Git clone failed"

Otherwise...

Everything looks good!

@typescript-automation

Copy link
Copy Markdown

Anders Hejlsberg (@ahejlsberg)
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 - native
Errors 41 41 ~ ~ ~ p=1.000 n=12
Symbols 115,480 115,480 ~ ~ ~ p=1.000 n=12
Types 96,945 96,945 ~ ~ ~ p=1.000 n=12
Memory Used 148,392k (± 0.45%) 148,338k (± 0.47%) ~ 146,295k 150,406k p=0.977 n=12
Memory Allocs 2,271,203 (± 0.01%) 2,268,233 (± 0.00%) -2,969 (- 0.13%) 2,267,845 2,268,507 p=0.000 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.041s (± 3.40%) 0.042s (± 3.97%) ~ 0.038s 0.048s p=0.090 n=12
Bind Time 0.012s (±12.49%) 0.013s (±13.03%) ~ 0.010s 0.019s p=0.295 n=12
Check Time 0.496s (± 1.26%) 0.487s (± 0.70%) -0.009s (- 1.76%) 0.482s 0.499s p=0.019 n=12
Emit Time 0.271s (± 2.00%) 0.262s (± 1.18%) 🟩-0.008s (- 3.11%) 0.255s 0.273s p=0.005 n=12
Total Time 0.826s (± 1.06%) 0.811s (± 0.62%) -0.014s (- 1.76%) 0.801s 0.831s p=0.002 n=12
angular-1 - native
Errors 3 3 ~ ~ ~ p=1.000 n=12
Symbols 847,447 (± 0.08%) 841,724 (± 0.09%) -5,723 (- 0.68%) 839,456 843,518 p=0.000 n=12
Types 249,858 (± 0.00%) 248,657 (± 0.00%) -1,201 (- 0.48%) 248,654 248,667 p=0.000 n=12
Memory Used 793,658k (± 0.06%) 790,960k (± 0.06%) -2,699k (- 0.34%) 789,429k 791,976k p=0.000 n=12
Memory Allocs 12,956,092 (± 0.04%) 12,913,586 (± 0.06%) -42,505 (- 0.33%) 12,906,822 12,954,131 p=0.000 n=12
Config Time 0.016s (± 1.51%) 0.016s ~ ~ ~ p=0.478 n=12
Parse Time 0.272s (± 2.83%) 0.275s (± 2.62%) ~ 0.259s 0.288s p=0.416 n=12
Bind Time 0.067s (±17.46%) 0.066s (±12.19%) ~ 0.058s 0.094s p=0.372 n=12
Check Time 0s 0s ~ ~ ~ p=1.000 n=12
Emit Time 1.636s (± 1.30%) 1.616s (± 1.13%) -0.021s (- 1.25%) 1.594s 1.693s p=0.034 n=12
Total Time 2.010s (± 1.42%) 1.990s (± 1.38%) ~ 1.944s 2.085s p=0.103 n=12
mui-docs - native
Errors 11,278 (± 0.04%) 11,279 (± 0.02%) ~ 11,271 11,282 p=0.720 n=12
Symbols 4,456,324 4,456,314 -10 (- 0.00%) ~ ~ p=0.000 n=12
Types 1,669,869 1,669,858 -11 (- 0.00%) ~ ~ p=0.000 n=12
Memory Used 5,404,069k (± 0.03%) 5,405,016k (± 0.03%) ~ 5,401,090k 5,409,078k p=0.443 n=12
Memory Allocs 50,697,779 (± 0.03%) 50,695,962 (± 0.04%) ~ 50,652,341 50,740,540 p=0.977 n=12
Config Time 0.016s (± 1.14%) 0.016s (± 1.14%) ~ 0.015s 0.016s p=1.000 n=12
Parse Time 0.560s (± 1.27%) 0.546s (± 2.74%) ~ 0.496s 0.581s p=0.103 n=12
Bind Time 0.002s 0.002s ~ ~ ~ p=1.000 n=12
Check Time 16.581s (± 0.24%) 16.545s (± 0.31%) ~ 16.412s 16.661s p=0.242 n=12
Emit Time 0.434s (± 1.47%) 0.437s (± 1.62%) +0.003s (+ 0.71%) 0.431s 0.462s p=0.015 n=12
Total Time 18.326s (± 0.11%) 18.308s (± 0.23%) ~ 18.198s 18.394s p=0.744 n=12
strada-build-src - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,394,339 1,394,286 -53 (- 0.00%) ~ ~ p=0.000 n=12
Types 443,465 443,436 -29 (- 0.01%) ~ ~ p=0.000 n=12
Memory Used 1,648,922k (± 0.26%) 1,647,785k (± 0.34%) ~ 1,637,805k 1,664,035k p=0.514 n=12
Memory Allocs 97,072,744 (± 0.04%) 96,959,569 (± 0.04%) -113,176 (- 0.12%) 96,873,569 97,049,235 p=0.001 n=12
Config Time 0.004s (±14.29%) 0.004s (±12.82%) ~ 0.003s 0.006s p=0.976 n=12
Parse Time 0.195s (± 1.88%) 0.200s (± 2.03%) ~ 0.190s 0.211s p=0.080 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.793s (± 0.32%) 1.784s (± 0.35%) -0.008s (- 0.46%) 1.773s 1.808s p=0.040 n=12
Emit Time 0.281s (± 3.34%) 0.282s (± 5.89%) ~ 0.243s 0.330s p=0.966 n=12
Total Time 24.580s (± 0.49%) 24.673s (± 0.94%) ~ 24.043s 25.312s p=0.410 n=12
strada-compiler - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 337,586 337,560 -26 (- 0.01%) ~ ~ p=0.000 n=12
Types 198,869 198,858 -11 (- 0.01%) ~ ~ p=0.000 n=12
Memory Used 319,500k (± 0.03%) 319,730k (± 0.08%) +230k (+ 0.07%) 319,342k 320,937k p=0.028 n=12
Memory Allocs 4,673,065 (± 0.01%) 4,667,245 (± 0.01%) -5,820 (- 0.12%) 4,665,813 4,668,552 p=0.000 n=12
Config Time 0.001s 0.001s ~ ~ ~ p=1.000 n=12
Parse Time 0.112s (± 5.06%) 0.117s (± 5.89%) ~ 0.102s 0.130s p=0.192 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.038s (± 0.42%) 1.035s (± 0.49%) ~ 1.025s 1.051s p=0.415 n=12
Emit Time 0.146s (± 8.83%) 0.128s (±13.87%) ~ 0.097s 0.164s p=0.138 n=12
Total Time 1.346s (± 1.07%) 1.337s (± 1.39%) ~ 1.303s 1.383s p=0.272 n=12
ts-pre-modules - native
Errors 87 87 ~ ~ ~ p=1.000 n=12
Symbols 305,317 305,293 -24 (- 0.01%) ~ ~ p=0.000 n=12
Types 181,984 181,978 -6 (- 0.00%) ~ ~ p=0.000 n=12
Memory Used 277,285k (± 0.02%) 277,209k (± 0.02%) -76k (- 0.03%) 277,098k 277,336k p=0.045 n=12
Memory Allocs 1,642,489 (± 0.01%) 1,639,436 (± 0.01%) -3,053 (- 0.19%) 1,639,076 1,639,693 p=0.000 n=12
Config Time 0.000s (±217.90%) 0.000s (±146.91%) ~ 0.000s 0.001s p=1.000 n=12
Parse Time 0.105s (± 4.29%) 0.100s (± 4.22%) ~ 0.090s 0.112s p=0.074 n=12
Bind Time 0.038s (± 7.66%) 0.040s (±11.26%) ~ 0.032s 0.052s p=0.637 n=12
Check Time 0.830s (± 0.80%) 0.829s (± 0.66%) ~ 0.806s 0.839s p=0.854 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 0.986s (± 0.80%) 0.983s (± 0.75%) ~ 0.961s 1.007s p=0.810 n=12
vscode - native
Errors 347 347 ~ ~ ~ p=1.000 n=12
Symbols 7,931,112 7,926,127 -4,985 (- 0.06%) ~ ~ p=0.000 n=12
Types 2,714,263 2,709,275 -4,988 (- 0.18%) ~ ~ p=0.000 n=12
Memory Used 5,357,067k (± 0.01%) 5,353,533k (± 0.01%) -3,534k (- 0.07%) 5,351,937k 5,355,216k p=0.000 n=12
Memory Allocs 41,190,465 (± 0.05%) 41,094,031 (± 0.03%) -96,434 (- 0.23%) 41,080,819 41,155,902 p=0.000 n=12
Config Time 0.063s (± 0.39%) 0.064s (± 0.51%) ~ 0.063s 0.064s p=0.089 n=12
Parse Time 1.630s (± 1.87%) 1.621s (± 1.96%) ~ 1.522s 1.680s p=0.724 n=12
Bind Time 0.337s (± 1.43%) 0.356s (± 7.18%) ~ 0.334s 0.469s p=0.064 n=12
Check Time 9.804s (± 0.26%) 9.636s (± 1.12%) -0.168s (- 1.71%) 9.297s 9.778s p=0.000 n=12
Emit Time 3.025s (± 0.65%) 3.194s (± 7.92%) ~ 2.939s 4.044s p=0.131 n=12
Total Time 14.946s (± 0.29%) 14.963s (± 1.05%) ~ 14.745s 15.509s p=0.193 n=12
webpack - native
Errors 531 531 ~ ~ ~ p=1.000 n=12
Symbols 850,254 850,121 -133 (- 0.02%) ~ ~ p=0.000 n=12
Types 385,198 385,177 -21 (- 0.01%) ~ ~ p=0.000 n=12
Memory Used 652,001k (± 0.03%) 651,993k (± 0.03%) ~ 651,629k 652,658k p=1.000 n=12
Memory Allocs 4,318,255 (± 0.03%) 4,313,931 (± 0.04%) -4,324 (- 0.10%) 4,311,987 4,322,581 p=0.000 n=12
Config Time 0.008s 0.008s ~ ~ ~ p=1.000 n=12
Parse Time 0.211s (± 2.42%) 0.220s (± 2.54%) 🔻+0.010s (+ 4.71%) 0.206s 0.234s p=0.013 n=12
Bind Time 0.048s (±16.21%) 0.045s (±11.34%) ~ 0.040s 0.070s p=0.965 n=12
Check Time 1.128s (± 1.29%) 1.159s (± 1.31%) +0.031s (+ 2.78%) 1.113s 1.203s p=0.001 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.419s (± 0.89%) 1.456s (± 1.00%) +0.037s (+ 2.63%) 1.413s 1.497s p=0.001 n=12
xstate-main - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,022,508 1,022,506 -2 (- 0.00%) ~ ~ p=0.000 n=12
Types 376,977 376,974 -3 (- 0.00%) ~ ~ p=0.000 n=12
Memory Used 603,518k (± 0.01%) 603,473k (± 0.01%) ~ 603,179k 603,652k p=0.340 n=12
Memory Allocs 4,755,912 (± 0.05%) 4,754,316 (± 0.04%) ~ 4,750,050 4,760,831 p=0.347 n=12
Config Time 0.003s 0.003s ~ ~ ~ p=1.000 n=12
Parse Time 0.146s (± 1.37%) 0.146s (± 3.52%) ~ 0.137s 0.160s p=0.467 n=12
Bind Time 0.042s (±14.44%) 0.045s (±18.52%) ~ 0.033s 0.072s p=0.721 n=12
Check Time 1.041s (± 1.01%) 1.029s (± 0.66%) ~ 1.006s 1.047s p=0.116 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.244s (± 1.16%) 1.234s (± 0.97%) ~ 1.200s 1.264s p=0.284 n=12
System info unknown
Hosts
  • native
Scenarios
  • Compiler-Unions - native
  • angular-1 - native
  • mui-docs - native
  • strada-build-src - native
  • strada-compiler - native
  • ts-pre-modules - native
  • vscode - native
  • webpack - native
  • xstate-main - native
Benchmark Name Iterations
Current pr 12
Baseline baseline 12

Developer Information:

Download Benchmarks

@typescript-automation

Copy link
Copy Markdown

Hey Anders Hejlsberg (@ahejlsberg), the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-automation

Copy link
Copy Markdown

Anders Hejlsberg (@ahejlsberg) Here are the results of running the top 400 repos with tsc comparing main and refs/pull/64018/merge:

Everything looks good!

@ahejlsberg

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) test top 1000

@ahejlsberg

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) test top1000

@typescript-automation

typescript-automation Bot commented Aug 25, 2026

Copy link
Copy Markdown

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

Command Status Results
test top1000 ✅ Started ✅ Results

@typescript-automation

Copy link
Copy Markdown

Anders Hejlsberg (@ahejlsberg) Here are the results of running the top 1000 repos with tsc comparing main and refs/pull/64018/merge:

Everything looks good!

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.

Stack overflow narrowing as const object assigned to loop variable it references

1 participant