Repository navigation
fix(bench): stop deleting packed-refs in invalidate_caches_auto - #2697
Merged
Merged
Conversation
`create_repo_at` ends with an explicit `git gc` (added in #2683 to fix the list-bench fixture race). gc packs every loose ref into `.git/packed-refs` and prunes the loose copies, so `packed-refs` becomes the only on-disk record of `refs/heads/main`. `invalidate_caches_auto` then deleted that file as part of its cold-cache reset — taking the only copy of the branch ref with it. The fallout surfaced one bench later: `wt stub`'s body has no template vars, so it survived; `wt with_vars` resolved `{{ commit }}` via `rev-parse main`, got an Err back, and Criterion panicked at warm-up of `dispatch/with_vars/warm/1`. The nightly benchmarks job has been red since the #2683 merge for this reason. `packed-refs` is git's primary ref storage post-gc, not a cache — there's no cold-cache equivalent to simulate by deleting it (the kernel page-cache isn't invalidated by `unlink` anyway). Drop the deletion, document why, and add a regression test that asserts `rev-parse main` still resolves after `invalidate_caches_auto`. Co-Authored-By: Claude Opus 4.7 <[email protected]>
This was referenced May 11, 2026
Closed
6 tasks done
max-sixty
added a commit
that referenced
this pull request
May 11, 2026
## Summary - Adds `picker_preview` benchmark group measuring "process spawn → all preview tasks drained" for `wt switch`'s interactive picker. - Introduces `WORKTRUNK_PREVIEW_BENCH=1`, an early-exit gate inside `handle_picker` that runs the full prelude (collect, speculative spawn, skeleton, initial + deferred precompute, `orchestrator.wait_for_idle()`) and returns before skim launches or any JSON / stderr I/O. Shares the dry-run path; behavior with the env var unset is unchanged. - Closes the coverage gap behind #2662 / #2683 / #2685 / #2704, which were tuned against `wt list` as a proxy because no direct picker measurement existed. ## Why this measurement Picker submits one preview-compute task per row to the global rayon pool. The user-visible quantity to optimize is the responsiveness window between picker launch and "all previews ready" (j/k navigation hits cached content). Option 1 from the task — headless wall clock to drain — is the cleanest measurable proxy and avoids the PTY route, which hits the documented nextest/SIGTTOU pain on `shell-integration-tests`. PTY-driven first-interactive-ready can be a follow-up. ## Variants - `picker_preview/warm/typical-8` - `picker_preview/cold/typical-8` Cold uses `BatchSize::PerIteration` (not `SmallInput`): `SmallInput` calls `setup` for an entire batch up front and then runs timed routines back-to-back, so only the first iter in each batch is genuinely cold — the rest hit a freshly populated `.git/wt/cache/`. `PerIteration` invalidates immediately before every measured iteration; setup is far cheaper than `wt switch`, so per-iter `Instant::now` doesn't dominate. `sample_size(10)` + `measurement_time(35s)` per #2685's lead — slow benches don't benefit from the default 30 samples. `cfg(unix)`-gated with a no-op `main` on Windows; the picker is Unix-only and `wt switch` (no args) hits the unavailable path before the env var is consulted. ## Sample run ``` picker_preview/warm/typical-8 time: [185.62 ms 191.72 ms 200.77 ms] picker_preview/cold/typical-8 time: [209.34 ms 226.23 ms 239.29 ms] ``` ## Test plan - [x] `cargo bench --bench picker_preview` runs cleanly on both variants - [x] `cargo run -- hook pre-merge --yes` — 3667 tests pass - [x] New `test_picker_preview_bench_produces_no_output` asserts `WORKTRUNK_PREVIEW_BENCH=1` keeps stdout/stderr empty (covers the env-gated branch, locks the no-I/O contract) - [x] Smoke test: `wt switch` with `WORKTRUNK_PREVIEW_BENCH` unset still hits the TTY error path (user-visible behavior unchanged) - [x] Smoke test: `WORKTRUNK_PICKER_DRY_RUN=1` still emits the cache JSON dump (regression check) - [x] `/review-codex` pass clean after iterating on three findings (packed-refs fix already on `main` via #2697 once branch was rebased; `BatchSize::PerIteration` for true per-iter invalidation; `cfg(unix)` gate for Windows) > _This was written by Claude Code on behalf of Maximilian Roos_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
create_repo_atends with an explicitgit gc(added in #2683 to fix the list-bench fixture race). gc packs every loose ref into.git/packed-refsand prunes the loose copies, so post-gcpacked-refsis the only on-disk record ofrefs/heads/main. `invalidate_caches_auto` then deleted that file as part of its cold-cache reset — taking the only copy of the branch ref with it.The fallout surfaced one bench later: `wt stub`'s body has no template vars, so it survived; `wt with_vars` resolved `{{ commit }}` via `rev-parse main`, got an `Err` back, and Criterion panicked at warm-up of `dispatch/with_vars/warm/1`. The nightly `benchmarks` job has been red since the #2683 merge for this reason (failed run, reported as #2693).
`packed-refs` is git's primary ref storage post-gc, not a cache — there's no cold-cache equivalent to simulate by deleting it (the kernel page-cache isn't invalidated by `unlink` anyway). Drop the deletion, document why, and add a regression test.
Test plan
Fixes #2693.
🤖 Generated with Claude Code