Repository navigation
v1.9.2 reuse array elements dropped by a shrink when decoding in place - #24
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
reececomo
marked this pull request as ready for review
November 10, 2026 10:35
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.
In-place decoding now reuses array element objects dropped by a shrink when the array grows again, so arrays of varying length stop allocating.
More details
Before,
_$readArraytruncated the target array, which discarded the element objects past the new length. The next longer packet then allocated fresh ones, along with any nested arrays and objects inside them. Elements dropped by a shrink are now kept in a per-array spare pool (aWeakMap) and handed back to_$readwhen the array grows. Scalar arrays are unaffected.In a probe of 1,000 in-place decodes of
{ frames: [{ seq, inputs: [{ x: Scalar8, y: Scalar8 }] }] }with varying lengths, new objects fell from 14,282 to 0 after warm-up.One behaviour changes: an element object removed by a shrink can reappear, overwritten, after a later grow. The existing deep-object test asserted the old behaviour, so that assertion now expects reuse.
🤖 Generated with Claude Code