Skip to content

refactor(perf): build every wt-perf fixture branch through one primitive - #3584

Merged
max-sixty merged 3 commits into
mainfrom
wt-perf-fixture-consolidation
Jul 25, 2026
Merged

max-sixty merged 3 commits into
mainfrom
wt-perf-fixture-consolidation

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Follow-up to #3548, which consolidated the wt-perf prune fixtures but left the branch builders diverged.

The refactor

Three generators had each grown their own way to create a fixture branch. add_history_spread_branches pointed a ref at an old commit, add_diverged_backdrop hand-rolled ~45 lines of index plumbing, and create_mixed_repo_at used checkout -b plus a return-to-main for two of its four states.

They are the same operation. A branch's state is entirely the pair (fork point, own-commit count): zero commits at an old fork is "behind" and at the tip is "identical"; a positive count from the tip is "ahead" and from anywhere else is two-sided "diverged". add_branch_with_commits takes that pair, and the mixed fixture's four-state rotation collapses to a table:

let (fork, commits) = match i % 4 {
    0 => (checkpoint, 0),                // behind
    1 => (base_tip.as_str(), 1 + i % 3), // ahead
    2 => (checkpoint, 1 + i % 3),        // diverged
    _ => (base_tip.as_str(), 0),         // identical to the tip
};

The checkout path is what actually mattered. git checkout of an old fork point on rust-lang/rust rewrites the whole tree (minutes per branch), which is why add_diverged_backdrop grew plumbing in the first place. Routing the mixed fixture through the same primitive removes the last checkout from fixture construction, so the main worktree is never touched and the fixture is no longer structurally barred from a rust-scale repo.

The win is structural. Fixture build time is unchanged: mixed-8-8 runs 3.25/3.28/3.71s after against 3.33/3.55/3.91s before, and mixed-24-120 14.9/15.7s against 15.5/23.5s. That is parity within noise, and the before-side spread swamps the difference.

The guards

These generators had nothing pinning their output. The benchmarks measure one wall-clock number, so a generator change that collapsed (say) "diverged" into "ahead" would keep every bench green while silently measuring a different repo. Three tests now assert the shapes directly, via merge-base --is-ancestor exit codes and porcelain status:

  • the full fixture's documented index % 4 rotation of branch and worktree states
  • the same fixture's zero-dimension contract (mixed-W-0 / mixed-0-B), which holds only because 0..0 never enters the loop that divides by branches
  • add_diverged_backdrop's own wiring: every member unintegrated, fork depths fanning across history, worktrees dirty only via untracked scratch, and populations that don't follow each other

Each was mutation-tested rather than trusted for being green. A clamped divisor gives left: 1, right: 0, and a fork spread collapsed onto the tip gives fork depths must fan out across history: [0, 0, 0, 0].

One thing to look at

Writing the guards turned up a docstring overclaim in two places. history_spread_shas samples newest-first, so index 0 is the default branch's own tip. That makes add_diverged_backdrop's "the default branch has advanced past every fork" and add_history_spread_branches's "behind-only" both false as written. The first is true in its only caller, where add_squash_merged advances the default branch on the very next line.

I corrected the docstrings rather than the sampling, and pinned the behavior with assert_eq!(depths[0], 0, "the newest sample is main's own tip"). Changing the sampling would shift the workload of every prune and list benchmark that uses the spread, moving Criterion's historical series with no rename to signal it, in exchange for one branch out of 24 to 120 gaining fork depth. Happy to flip it if you'd rather; it is documented and asserted either way.

Verification

hook pre-merge green (4542 tests), and cargo bench --bench list full runs end to end against the rebuilt fixture. Shape verified at benchmark scale rather than only at the test's N = 8: a real mixed-24-120 holds the rotation through br-0118. The refactor is content-identical for the backdrop (same blob content, filenames, commit messages, plumbing sequence) and structurally identical for the mixed fixture (same fork points and commit counts, since 0..=(i%3) and 1 + i%3 agree).

This was written by Claude Code on behalf of max

Three generators each grew their own way of creating a fixture branch:
`add_history_spread_branches` pointed a ref at an old commit,
`add_diverged_backdrop` hand-rolled ~45 lines of index plumbing, and
`create_mixed_repo_at` used `checkout -b` plus a return-to-main for two of
its four states.

They are the same operation. A branch's state is entirely the pair (fork
point, own-commit count): zero commits at an old fork is "behind" and at the
tip is "identical"; a positive count from the tip is "ahead" and from
anywhere else is two-sided "diverged". `add_branch_with_commits` takes that
pair, and the mixed fixture's rotation collapses to a six-line table.

The checkout path is what actually mattered. `git checkout` of an old fork
point on rust-lang/rust rewrites the whole tree, minutes per branch, which
is why `add_diverged_backdrop` grew plumbing in the first place. Routing
the mixed fixture through it removes the last checkout from fixture
construction, so the main worktree is never touched and the fixture is no
longer structurally barred from a rust-scale repo. Fixture build time is
unchanged at both `mixed-8-8` and `mixed-24-120`.

Add the guards that were missing before the refactor, so the shapes the
benchmarks measure are pinned by something other than a wall-clock number:

- the `full` fixture's documented `index % 4` rotation of branch and
  worktree states, asserted via `merge-base --is-ancestor` exit codes and
  porcelain status
- the same fixture's zero-dimension contract (`mixed-W-0` / `mixed-0-B`),
  which holds only because `0..0` never enters the loop that divides by
  `branches`
- `add_diverged_backdrop`'s own wiring: every member unintegrated, fork
  depths fanning across history, worktrees dirty only via untracked
  scratch, and populations that don't follow each other

Each guard was mutation-tested rather than trusted for being green.

Writing them turned up a docstring overclaim: `add_diverged_backdrop` says
the default branch has advanced past every fork, but the history spread's
newest sample is the tip itself, so index 0 of each population is strictly
ahead. It is true in the only caller, where `add_squash_merged` advances
the default branch on the next line. Correct the docstring rather than the
sampling, which would change every prune benchmark's workload.
The test module had grown two ways to read `git status --porcelain`: a
raw-stdout closure, and a `capture_git` call. They are not equivalent —
`capture_git` trims, and porcelain's leading column is what separates ` M`
(unstaged) from `M ` (staged). The trimming variant passed only because
every line it happened to see began with `??`. Keep the correct one, as a
module-level helper both callers share.

Also correct `add_history_spread_branches`'s docstring, which claims the
branches are "behind-only". The spread samples newest-first, so
`feature-000` sits exactly on the tip — the same overclaim already fixed on
`add_diverged_backdrop`, and the shape the GH #461 rust-repo bench builds.
@max-sixty
max-sixty merged commit a5ca8a1 into main Jul 25, 2026
39 checks passed
@max-sixty
max-sixty deleted the wt-perf-fixture-consolidation branch July 25, 2026 00:46
@max-sixty max-sixty mentioned this pull request Jul 25, 2026
max-sixty added a commit that referenced this pull request Jul 25, 2026
Cuts v0.69.2, and fixes the Windows code-signing path it depends on.

## The signing fix

v0.69.1 shipped an unsigned `wt.exe` under a green run and a
**Completed** SignPath signing request. `archive: false` (#3566) had
already made the GitHub artifact name
`worktrunk-x86_64-pc-windows-msvc.zip`, and SignPath names its download
after the artifact — so with `output-artifact-directory: target/distrib`
the signed zip landed at `worktrunk-x86_64-pc-windows-msvc.zip.zip`,
beside the untouched unsigned build. The checksum step and the release
upload both kept reading the original. Confirmed by parsing the
published asset's PE certificate table: `size=0`.

The download now goes to a scratch directory and whatever single file
lands there replaces the built zip, so SignPath's naming isn't
load-bearing.

## Verification, because this failure is invisible

Signing is `continue-on-error` by design (self-signed test certificate
pending SignPath's OSS review), so nothing in the logs distinguishes
"signed" from "silently unsigned" — which is how it slipped through
twice, two different ways. `.github/verify-windows-signature.py` reads
the zip's PE certificate tables directly, and runs at two points with
distinct jobs:

- **before the overwrite** — an unsigned release is tolerable while the
certificate is a test one; a corrupt one never is, so the replacement
has to verify before it can clobber a good build.
- **after** — reports what the release actually ships, which is the
question the logs never answered.

## Rehearsed before landing

The signing path only runs on a tag, so each question about it used to
cost a release. This chain was instead run on a Windows runner against
the already-published v0.69.1 zip (identical bytes, no build):

```
saved to …\target\signpath\worktrunk-x86_64-pc-windows-msvc.zip.zip
git-wt.exe: certificate table 8480 bytes
wt.exe:     certificate table 8472 bytes
→ mv → target/distrib/worktrunk-x86_64-pc-windows-msvc.zip
target/distrib/worktrunk-x86_64-pc-windows-msvc.zip: all 2 executables signed
worktrunk-x86_64-pc-windows-msvc.zip: OK   (checksum matches)
```

That also settled the open question behind #3556: SignPath returns the
signed zip itself, not a wrapper, so `skip-decompress: true` is correct
— the extract mode does explode it into loose files.

## Release contents

`wt remove`'s fsmonitor sweep (#3581), the troubleshooting doc trim, and
this fix. The two refactors in range (#3582, #3584) are
behavior-preserving and omitted per convention.

Local gate green (4547 passed). Changelog entries verified against the
diffs by subagent; two claims corrected (the doc entry's rationale, and
an overclaim attributing v0.69.0's unsigned binary to this bug rather
than the separate upload failure #3566 fixed). Data-loss surface
reviewed across the cumulative diff.

> _This was written by Claude Code on behalf of max_
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