perf: enlarge BoxedValues int cache to eliminate iterator index boxing - #653
Merged
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Iterators box the per-item index through BoxedValues.Int on every
iteration; indexes beyond the cache allocate a fresh 24-byte box each
time, which is the dominant remaining allocation in list rendering
(e.g. 23.5KB per render of a 1000-item {{#each}}). 1024 cached boxes
(~32KB of process-lifetime statics) cover effectively all template
loops.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
rexm
enabled auto-merge
August 5, 2026 04:42
|
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.



Summary
Follow-up to #652. Iterators box the per-item index through
BoxedValues.Inton every iteration; indexes beyond the cache (previously 0–19) allocate a fresh 24-byte box each time. After #651/#652 removed the larger allocation sources, this was the dominant remaining allocation in list rendering — e.g. 23.5KB per render of a 1000-item{{#each}}, identical for object and dictionary data.MemoryDiagnoseron theLargeArrayandEndToEndsuites so allocation deltas are visible there (separate commit).All 1840 tests pass.
Benchmarks
MediumRun (LaunchCount=1, 15 iterations), Apple M4, .NET 10. Baseline is current master @ 9ee2d48 (i.e. after #651/#652) plus the MemoryDiagnoser commit.
Time deltas are all within the ±3% cross-run noise band observed on this machine (the −9.1% and −6.2% outliers included) — this change is about allocation, not speed.
LargeArraydrops exactly the 1,004 newly-cached index boxes (~24KB/render); its remaining megabytes are theList<int>values being boxed when read asobject— a separate mechanism, out of scope here.🤖 Generated with Claude Code