Skip to content

Reuse local input hashes when lowering Bzlmod repositories - #594

Merged
tinder-maxwellelliott merged 1 commit into
Tinder:masterfrom
tamird:reuse-bzlmod-repository-input-hashes
Oct 31, 2026
Merged

tinder-maxwellelliott merged 1 commit into
Tinder:masterfrom
tamird:reuse-bzlmod-repository-input-hashes

Conversation

@tamird

@tamird tamird commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Generating hashes walked a local module's directory tree twice. The module definition and its synthetic target both needed the same digest. Workspace files named by repository attributes, such as override patches, were also read twice. Multiple apparent names or extension views repeated the target work.

The module definition and target now share the two local digests for their repository record. The lowerer reads the original attribute paths, normalizes the owned attributes once, and moves the prepared rule into its last output. A separate record still reads its own inputs, even if its canonical name matches an earlier record.

In four paired local generate-hashes runs, median repository lowering went from 2.59 s to 1.64 s and median generator wall time from 4.72 s to 3.65 s. Each binary ran first in two pairs, after one warm-up. The runs replayed a complete show_repo response with 144,774 records, including 432 modules, and a bounded ordinary query. Module graph and mapping responses were reacquired at the same checkout revision and replayed identically. The generators read the local files from that checkout. The timings exclude live Bazel discovery. All eight outputs agreed byte for byte across 192,065 target hashes and 3,002,048 ordered dependency edges.

The regression changes a workspace patch after the module-definition pass and before the module's first target. It checks the original digest on both apparent names and their extension views, and the changed digest on a later independent repository.

Prepared by Codex on behalf of Tamir Duberstein.

A module's synthetic target and the definition inherited by its extension
repositories both hashed the same workspace inputs. For a local_repository
this meant walking the same directory tree twice. Additional apparent
names and extension views repeated the target preparation.

Read local inputs from the original attribute paths, then normalize the
owned attributes in place. Keep each module record's two local digests
for its target and build one rule for its apparent names and views. Use
the input position so separate records with the same canonical name still
read their own inputs.

Test the boundary by changing a patch after module definitions have been
computed. Both aliases and their extension views use the first digest,
and a later independent repository reads the changed patch.
@tinder-maxwellelliott
tinder-maxwellelliott merged commit 5336b4d into Tinder:master Oct 31, 2026
19 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