Repository navigation
Presize checker type-list cache keys - #64777
Merged
Jake Bailey (jakebailey) merged 1 commit intoOct 13, 2026
Merged
Jake Bailey (jakebailey) merged 1 commit into
Jake Bailey (jakebailey) merged 1 commit into
Conversation
Jake Bailey (jakebailey)
added this pull request to stack #64792
October 13, 2026 17:37
Jake Bailey (jakebailey)
marked this pull request as ready for review
October 13, 2026 17:42
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The reservation logic preserves byte-stream behavior and is covered across inline and overflow boundaries.
0 open findings
What changed in this PR
Presizes checker cache-key buffers to avoid repeated allocations while preserving encoded hashes.
Changes:
- Adds capacity reservation for type-list encoding.
- Tests hash stability and allocation boundaries.
- Adds focused allocation benchmarks.
| File | Description |
|---|---|
tsc/internal/checker/checker.go |
Reserves type-list key capacity before encoding. |
tsc/internal/checker/types_test.go |
Adds correctness, allocation, and benchmark coverage. |
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.
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)
force-pushed
the
jakebailey/mem/presized-type-list-keys
branch
from
October 13, 2026 20:06
2a39414 to
161e925
Compare
Base automatically changed from
jakebailey/mem/batched-type-allocs
to
jakebailey/mem/compressed-link-stores
October 13, 2026 20:06
Jake Bailey (jakebailey)
deleted the
jakebailey/mem/presized-type-list-keys
branch
October 13, 2026 20:06
Jake Bailey (jakebailey)
restored the
jakebailey/mem/presized-type-list-keys
branch
October 13, 2026 20:15
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.