Skip to content

perf: skip the repeat bazel mod graph calls once Bzlmod is known to be off - #659

Merged
tinder-maxwellelliott merged 1 commit into
Tinder:masterfrom
maxwellE:perf/skip-repeat-mod-graph
Nov 16, 2026
Merged

tinder-maxwellelliott merged 1 commit into
Tinder:masterfrom
maxwellE:perf/skip-repeat-mod-graph

Conversation

@tinder-maxwellelliott

Copy link
Copy Markdown
Collaborator

In a workspace with Bzlmod disabled, generate-hashes asked Bazel the same question up to three times. With a MODULE.bazel file present, the run was:

  1. info release output_base starlark-semantics
  2. mod graph --output=json (discovery survey; fails)
  3. mod dump_repo_mapping "" (Bzlmod probe; fails)
  4. mod graph (probe fallback; fails the same way as 2)
  5. query
  6. mod graph --output=json (hash-file metadata; fails the same way as 2)

Calls 4 and 6 can only repeat the answer of call 2 (or of call 4 when there is no MODULE.bazel). Each one is a Bazel client start plus a server round trip.

Without MODULE.bazel this saves one Bazel invocation per generate-hashes; with one, two. Bzlmod-enabled workspaces run the same commands as before.

Output is unchanged: hashes, dependency edges and impacted sets are identical on small, medium and large. A new test runs generate-hashes against a fake Bazel with Bzlmod off, with and without MODULE.bazel, and checks that mod graph runs once and the module graph stays absent.

Performance (make perf-proof, base 66fcee3 vs this branch, cargo --release on both sides, small + medium + large, 5 interleaved iterations): IMPROVED, no regressions.

workload stage base CPU candidate CPU delta p
small generate-hashes @base, cold 0.145s 0.119s -17.8% 0.008
small generate-hashes @base, warm 0.132s 0.105s -20.9% 0.008
small generate-hashes @Head -d, warm 0.141s 0.104s -25.8% 0.008
medium generate-hashes @base, cold 0.225s 0.202s -10.2% 0.056
medium generate-hashes @base, warm 0.214s 0.183s -14.5% 0.206
medium generate-hashes @Head -d, warm 0.209s 0.186s -10.9% 0.151
large generate-hashes @Head -d, warm 0.481s 0.439s -8.7% 0.056

The saving is a fixed ~25-35 ms of client CPU per generate-hashes, so it shows most on small workspaces; medium and large move the same direction but stay under significance at n=5. Peak RSS and get-impacted-targets are unchanged.

Test environment: the benchmark sandbox cannot reach bcr.bazel.build, so the measured workspaces ran through a wrapper that adds --noenable_bzlmod --enable_workspace to every command and execs the Bazel 8.8.2 client directly (no bazelisk in between, so client start-up is not inflated). Both sides ran with the same wrapper. That is also the configuration this change targets.

Tests: cargo test --release --lib, 299 pass (the 10 server remote-cache and GCS tests were skipped: they need network the sandbox does not have and do not touch this code). rustfmt --check is clean.

🤖 Generated with Claude Code

@tinder-maxwellelliott
tinder-maxwellelliott merged commit b79c150 into Tinder:master Nov 16, 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.

1 participant