Repository navigation
Presize checker type-list cache keys - #64794
Merged
Jake Bailey (jakebailey) merged 1 commit intoOct 14, 2026
Merged
Jake Bailey (jakebailey) merged 1 commit into
Jake Bailey (jakebailey) merged 1 commit into
Conversation
Large type lists repeatedly grow temporary hash buffers even though
their encoded length is already known. These discarded allocations
account for a substantial part of checker allocation traffic.
Reserve enough capacity before writing each list, retaining the small
inline path and the exact existing hash byte stream. Allocation tests
cover the inline boundary and large lists, and a fresh-program benchmark
includes parsing and binding rather than relying only on warmed ASTs.
CPU wall timings are noisy on this machine; report bytes and allocation
counts instead.
goos: linux
goarch: amd64
pkg: github.com/microsoft/TypeScript/tsc/internal/checker
cpu: Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz
│ key-before.txt │ key-reserve.txt │
│ B/op │ B/op vs base │
TypeListKey/8-20 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=6) ¹
TypeListKey/46-20 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=6) ¹
TypeListKey/47-20 576.0 ± 0% 208.0 ± 0% -63.89% (p=0.002 n=6)
TypeListKey/256-20 2.375Ki ± 0% 1.125Ki ± 0% -52.63% (p=0.002 n=6)
TypeListKey/4096-20 81.25Ki ± 0% 18.00Ki ± 0% -77.85% (p=0.002 n=6)
geomean ² -48.03% ²
¹ all samples are equal
² summaries must be >0 to compute geomean
│ key-before.txt │ key-reserve.txt │
│ allocs/op │ allocs/op vs base │
TypeListKey/8-20 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=6) ¹
TypeListKey/46-20 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=6) ¹
TypeListKey/47-20 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.002 n=6)
TypeListKey/256-20 4.000 ± 0% 1.000 ± 0% -75.00% (p=0.002 n=6)
TypeListKey/4096-20 13.000 ± 0% 1.000 ± 0% -92.31% (p=0.002 n=6)
geomean ² -60.50% ²
¹ all samples are equal
² summaries must be >0 to compute geomean
Jake Bailey (jakebailey)
added this pull request to stack #64805
October 13, 2026 20:16
Jake Bailey (jakebailey)
removed this pull request from stack #64805
October 13, 2026 20:49
Jake Bailey (jakebailey)
added this pull request to stack #64806
October 13, 2026 20:50
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The reservation logic preserves encoding behavior and has focused correctness and allocation coverage.
0 open findings
What changed in this PR
Presizes checker type-list cache keys to reduce temporary buffer allocations without changing hashes.
Changes:
- Reserves encoded type-list capacity before writing.
- Adds hash-correctness and allocation-boundary tests.
- Adds focused key and fresh-program benchmarks.
| File | Description |
|---|---|
tsc/internal/checker/checker.go |
Presizes overflow buffers for type-list keys. |
tsc/internal/checker/types_test.go |
Tests correctness and allocation behavior. |
tsc/internal/checker/checker_test.go |
Benchmarks fresh-program checking. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Anders Hejlsberg (ahejlsberg)
approved these changes
Oct 13, 2026
Jake Bailey (jakebailey)
deleted the
jakebailey/mem/presized-type-list-keys
branch
October 14, 2026 01:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Large type lists repeatedly grow temporary hash buffers even though their encoded size is known up front.
Part of the memory optimization stack summarized in #64734.
Replaces #64777, which GitHub closed as merged when the stack was reordered.