Skip to content

Reuse completed dependency hashes across repository hubs - #564

Merged
tinder-maxwellelliott merged 3 commits into
Tinder:masterfrom
tamird:codex/bazel-diff-share-extension-inputs
Oct 25, 2026
Merged

tinder-maxwellelliott merged 3 commits into
Tinder:masterfrom
tamird:codex/bazel-diff-share-extension-inputs

Conversation

@tamird

@tamird tamird commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

When a Bzlmod extension exposes several imported repository hubs, each can have the same ordered list of unimported siblings. Hash generation currently allocates that list and walks its child hashes once per hub.

Share the list for hubs with identical inputs. Once every child has a completed rule digest, each hub can reuse the ordered labels and SHA-256 state while hashing its own definition. A missing digest, an unfinished cycle, or a source input uses the usual traversal. The new cycle test compares both hashes and expanded edges against that traversal. The extension flow test also checks that streamed definition hashing uses the queried rule when target deduplication keeps it over a synthetic repository with the same label.

On the two-extension fixture from #562, six alternating runs per binary on macOS with eight Rayon threads reduced median elapsed time from 1.332 s to 0.982 s and median peak RSS from 834 MB to 658 MB. Every run wrote byte-identical hash and dependency-edge files. A separate 192,000-target ordinary graph took 0.730 s before and 0.722 s after across eight runs per binary.

To reproduce the two-extension result, build bazel build --config=release //:bazel-diff at v66.0.0 and measured commit 2fb0c34. Pass those two executables to the existing benchmark script. Reproduction script

Codex for Tamir.

Every imported hub from one module extension depends on the same
unimported repositories. A large extension can therefore format, sort
and traverse the same thousands of labels for hundreds of rules.

Share the ordered sibling list when no module dependency or self-edge
changes it. Once every child has a completed rule digest, reuse the
ordered label bytes and transitive hash state. Each hub still hashes
its own definition, and the ordinary traversal handles incomplete
children and sources. Raw query results and edge files retain their
expanded labels.

Codex for Tamir.
A queried //external rule can share a label with a synthetic
repository. Deduplication keeps the queried rule, so streamed hashing
must use the same winner.

Extend the existing extension fixture with that overlap and compare
the streamed hash with hashing the deduplicated target list. On macOS,
the focused Bazel case failed under a controlled change that kept the
first prepared definition for a duplicate label, and passed with the
current implementation. The Bazel format check passed.

Codex for Tamir.
@tamird
tamird force-pushed the codex/bazel-diff-share-extension-inputs branch from ceefb5a to 94f2b4f Compare October 25, 2026 01:06
@tinder-maxwellelliott
tinder-maxwellelliott merged commit fd3651e into Tinder:master Oct 25, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants