Problem
On a clean tree, a gate leg whose bench binary has not changed still builds both sides. measure_ref_interleaved enters the merge-base worktree, builds the base bench binary purely to compute a digest, then prints "bench binaries identical" and takes the short circuit. For such a leg the base build is essentially the whole cost.
This is the common case on master, where the gate usually runs on changes that touch only some crates. In a make gate run across the seven bench crates, most legs are in exactly this state.
Proposal
The base digest is a pure function of what runcache::key already pins: merge-base sha, rustc, codegen-units, rustflags, cpu model, harness versions, and the pkg/features/target scope. Store the digest under that key when it is computed.
A later leg can then load the stored base digest, compare it against head's digest, and short-circuit without entering the worktree at all. The worktree build is needed only when the digests differ, or when nothing is stored for that key.
The trust argument is the one the code already makes for by_binary reuse: byte-identical machine code under identical conditions is the same measurement, whatever commit built it.
Expected effect
An unchanged leg costs a head build plus the cheap identical pass, instead of a head build, a base build, and the pass.
Notes
Depends on the digest covering every ALLOC+CONTENTS section rather than .text alone, so that a data-only change cannot read as identical. That widening is part of the inner-loop branch and should land first.
Problem
On a clean tree, a gate leg whose bench binary has not changed still builds both sides.
measure_ref_interleavedenters the merge-base worktree, builds the base bench binary purely to compute a digest, then prints "bench binaries identical" and takes the short circuit. For such a leg the base build is essentially the whole cost.This is the common case on master, where the gate usually runs on changes that touch only some crates. In a
make gaterun across the seven bench crates, most legs are in exactly this state.Proposal
The base digest is a pure function of what
runcache::keyalready pins: merge-base sha, rustc, codegen-units, rustflags, cpu model, harness versions, and the pkg/features/target scope. Store the digest under that key when it is computed.A later leg can then load the stored base digest, compare it against head's digest, and short-circuit without entering the worktree at all. The worktree build is needed only when the digests differ, or when nothing is stored for that key.
The trust argument is the one the code already makes for
by_binaryreuse: byte-identical machine code under identical conditions is the same measurement, whatever commit built it.Expected effect
An unchanged leg costs a head build plus the cheap identical pass, instead of a head build, a base build, and the pass.
Notes
Depends on the digest covering every ALLOC+CONTENTS section rather than
.textalone, so that a data-only change cannot read as identical. That widening is part of the inner-loop branch and should land first.