Repository navigation
perf: release dropped attribute storage after prehashing each queried rule - #615
Merged
tinder-maxwellelliott merged 1 commit intoNov 3, 2026
Conversation
… rule prehash_rule kept only tags and visibility via Vec::retain, which leaves the decoded buffer allocated. Attribute is 464 bytes and a queried rule carries dozens of attributes, so every rule pinned tens of KB of dead capacity until hashing finished. shrink_to_fit after the retain returns it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KJs3XytsGbjrXc37W1GZP5
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the prehashing attribute-capacity cleanup.
No open issues 🎉
What changed in this PR
This PR reduces memory retained during rule prehashing by releasing unused attribute-vector capacity after keeping only tags and visibility, without changing hash computation.
Changes:
- Replace empty-vector cleanup with
shrink_to_fit()to reclaim unused capacity for all prehashed rules. - Extend the existing prehash test to assert that attribute capacity equals length.
| File | Description |
|---|---|
src/hash.rs |
Reclaims unused attribute storage after prehashing and adds a capacity assertion to the existing test. |
Review effort: Balanced
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
prehash_rulehashes a rule's attributes as soon as its query batch is decoded and then keeps onlytagsandvisibilitywithVec::retain.retaindrops the removed attributes' contents but keeps the vector's buffer.Attributeis 464 bytes and every queried rule carries dozens of them (all implicit attributes are in the proto), so each rule pinned tens of KB of dead capacity until hashing finished. On the large synthetic workspace that was about 420 MiB of the process's 665 MiB peak.The fix calls
shrink_to_fit()after the retain (which also covers the existing empty case). The existing prehash test now asserts capacity equals length.Hash output, dependency edges and impacted sets are byte-identical on every workload.
Performance (
make perf-proof)Verdict: IMPROVED, no regressions. Linux, 2 vCPU / 7.8 GiB, Bazel 8.8.2, 5 interleaved iterations,
--builder cargo(the--config=releasebuild needs hosts this environment cannot reach). Base 6177715 (71.0.0), candidate tree 87ef848.get-impacted-targets is unchanged (it does not query). The CPU gain is mostly system time (page faults on the retained buffers). The full harness report is perf-proof-summary.md.
Testing
cargo test --release --lib: 253 passedmake perf-proof: correctness table identical on small, medium and largeClaude for Maxwell