Repository navigation
perf(hash): release empty rule attribute buffers after prehashing - #577
Merged
tinder-maxwellelliott merged 1 commit intoOct 26, 2026
Conversation
Rule preprocessing retains tags and visibility after computing the definition digest. If neither attribute survives, drop the vector's backing allocation before storing the rule for graph hashing.
tinder-maxwellelliott
approved these changes
Oct 26, 2026
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.
Ordinary query preprocessing hashes each rule definition, then drops every attribute except tags and visibility. When neither survives,
Vec::retainleaves the empty vector holding its allocation until graph hashing releases the rule. This change drops that allocation immediately. The new test checks both the definition digest and the empty vector’s capacity.I replayed a synthetic ordinary query containing 160,000 rules. Every rule has three discardable attributes, and 16,000 also have tags. Both optimized binaries ran on macOS arm64 with eight Rayon threads. After one warm-up per binary, I ran four pairs, with each binary going first twice. The complete hash and edge files matched in all ten runs.
wait4Peak RSS fell in all four pairs. The 170.9 MiB difference between medians exceeds the larger within-binary range of 27.3 MiB. Elapsed time varied by up to 0.523 s within a binary, so this measurement supports a memory improvement.
Reproduce the input and comparison
Build
//:bazel-diffwithbazel build -c opt //:bazel-diffat each revision. Savebazel-bin/src/bazel-diffasstockfor the parent andcandidatefor the PR in a temporary directory. The query replay uses the public fixture encoder and Bazel stand-in from the earlier ordinary-query benchmark. Parent revision · Fixture helperFrom that directory, download the helper, save the Python below as
reproduce.py, and run it with Python 3.11 or newer.The generated query is 26,448,878 bytes and has SHA-256
4e77fb01093e9bdfd2a0b9d73157dc5bbf3b1fe20db3a908640f3164489f28a4. The hash file is 24,800,001 bytes with SHA-25692e15eff56d4cb4c2d7839575242fbac6b870aa3dbbb86f723903410f4dfeb79. The edge file is 6,079,984 bytes with SHA-256c2724f4c722097492251d4917eb8ac1a075571bcb642ee8bc783e31ab793bc0a.Codex for Tamir.