Repository navigation
Only pre-size the printer buffer when printing a whole file - #64972
Jake Bailey (jakebailey) wants to merge 1 commit into
Conversation
Write grew the writer by the full source file length for every call, including when printing a single type node for typeToString or the type baselines. Each resulting string then pinned a buffer the size of the file; for largeControlFlowGraph.ts the types baseline retained over 3GB this way, which exhausts the 4GB wasm address space.
|
TypeScript Bot (@typescript-bot) perf test this faster |
There was a problem hiding this comment.
🟢 Approval recommended
The narrow guard preserves whole-file preallocation without changing printed output, and no blocking issues were identified.
No open issues 🎉
What changed in this PR
This PR reduces unnecessary memory allocation in the compiler’s printer by limiting buffer pre-sizing to whole-file printing.
Changes:
- Pre-size the buffer only when the node being printed is the supplied source file.
- Avoid reserving whole-file capacity when printing individual nodes.
| File | Description |
|---|---|
tsc/internal/printer/printer.go |
Restricts source-length buffer preallocation to whole-file printing. |
Review effort: Balanced
|
Jake Bailey (@jakebailey), the perf run you requested failed. You can check the log here. |
1 similar comment
|
Jake Bailey (@jakebailey), the perf run you requested failed. You can check the log here. |
|
Jake Bailey (@jakebailey) Here they are:
Provisional hosted-runner results: these VMs are not the dedicated benchmark machines. Results may be noisier and are not comparable to the historical series. For comparisons, both revisions of each scenario ran on the same VM. tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This has been wasting a whole bunch of memory on printing.