Repository navigation
Reserve room for a whole vector in VecWriter with simd - #387
Merged
Kerollmops merged 3 commits intoOct 27, 2026
Merged
Conversation
Kerollmops
requested changes
Oct 26, 2026
Kerollmops
left a comment
Member
There was a problem hiding this comment.
Hey @emschwartz 👋
Thanks for the contribution. However, you'll have to rebase over #385 👍
Have a nice week 🌵
emschwartz
force-pushed
the
vecwriter-simd-reserve
branch
from
October 26, 2026 18:35
8ae7305 to
7664a0c
Compare
Kerollmops
approved these changes
Oct 27, 2026
Kerollmops
force-pushed
the
vecwriter-simd-reserve
branch
from
October 27, 2026 13:15
5b3e0a6 to
9f21514
Compare
`visit_vector` appends all eight lanes and then truncates to the ones that matched, so a write near the end of the reserved space grows the Vec even though the output fits. Intersecting 500 values with a superset of 4000 reserves 500 and returns a Vec with capacity 1000, and `into_inner` does not shrink it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Upstream made SIMD unconditional, so `#[cfg(feature = "simd")]` never matched and the extra capacity and its test were compiled out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XGMzezWxjMNNrZCr1oDKCz
The vector algorithms only call `visit_vector` when both inputs hold a whole vector, so an output bound under 8 never needs the padding. Adding it anyway moves a 5-value result into a larger allocation size class, which made `ArrayStore -= &ArrayStore` on 5-value arrays take 105ns instead of 60ns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XGMzezWxjMNNrZCr1oDKCz
Kerollmops
force-pushed
the
vecwriter-simd-reserve
branch
from
October 27, 2026 13:20
9f21514 to
7615340
Compare
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.
Stacked on #385: only the last commit is new.
With
simd,VecWriter::visit_vectorappends all eight lanes and then truncates to the ones that matched. A vector write within eight slots of the reserved capacity therefore grows the Vec even though the output fits, andinto_innerdoes not shrink it. Intersecting 500 values with a superset of 4000 reserves 500 and returns a Vec with capacity 1000.Reserving eight extra slots under
simdavoids the regrow. The added test fails without it. This is about memory, not speed: over 3 runs on the machines from #385, timings were within 1% of that PR.Authored with Claude (claude-opus-5-5).