Skip to content

Cache the merge-base digest so an unchanged leg skips the base build #155

Description

@Verdenroz

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions