Repository navigation
docs(perf): add picker/collect phase timings and trace instrumentation - #2250
Merged
Merged
Conversation
Replace the worktree-only estimate with a more accurate calculation that accounts for branches when determining preview window height. The new logic short-circuits once the estimate reaches MAX_VISIBLE_ITEMS, since additional rows have no effect on the height computation. Local branches are included as a superset of worktree branches (taking the max), while remote branches are summed.
- Instrument handle_picker with six trace_instant markers covering the main-thread pre-collect phases (config resolution through collect spawn). - Fire "Skeleton rendered" from the picker's progressive-handler path in collect::collect so both wt list and wt switch share a marker set. - New wt-perf phases <list|switch> driver: runs the binary N times against a reproducible repo, parses [wt-trace] entries, aggregates per-phase median/p95/min/max durations and command counts. list runs pass --progressive so the skeleton instants fire under stdout redirect. Default --wt points at target/release/wt with a pre-flight check. - Backfill measured phase timings into the picker and collect module docstrings (worktrunk dev repo, 7 worktrees, warm caches, release build). Co-authored-by: Claude <[email protected]>
The previous commit added `wt-perf phases`, which mostly duplicated infrastructure already in the repo: - End-to-end timings: `cargo bench --bench time_to_first_output` (via WORKTRUNK_FIRST_OUTPUT) already covers `switch`, `list`, `remove` with proper criterion statistics. - Per-phase breakdown: `wt-perf trace` emits Chrome Trace Format, and `benches/CLAUDE.md` documents a ready-made `trace_processor` SQL query that computes phase durations from instant markers. Keep the `trace_instant` markers in `handle_picker` and the `"Skeleton rendered"` emission from the picker's progressive-handler path — those feed both workflows and are the actually-valuable part. Rewrite the docstring "reproducing" sections to point at `cargo bench time_to_first_output` and `wt-perf trace` instead of the removed subcommand. Co-authored-by: Claude <[email protected]>
# Conflicts: # src/commands/picker/mod.rs
The old examples piped stderr through grep, which was the wt-perf phases workflow. Now that phases was dropped in favour of existing bench tooling, simplify to process substitution with -q flag. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
Apr 16, 2026
3 tasks done
max-sixty
added a commit
that referenced
this pull request
May 9, 2026
## Summary The TODO in `src/commands/picker/mod.rs` asking to "dedupe `list_worktrees` calls between `num_items_estimate` and `collect::collect`" has already been resolved. `Repository::list_worktrees` has been cached on `RepoCache` since 2114fda (#2375), and the picker shares that cache across its main thread and the bg `picker-collect` thread via `Arc<RepoCache>` — `repo.clone()` shares the `OnceCell<Vec<WorktreeInfo>>`, so the second call is a memory hit. The `RepoCache::worktrees` docstring already states the contract: *"The picker warms this on the main thread (for its preview-window sizing estimate) so the background `collect::collect` pass hits memory instead of respawning the subprocess on the critical path to skeleton."* The TODO was originally added in #2250 and partially walked back in #2368 (the parenthetical noting the branch-inventory cache), but the body was never updated when #2375 closed the worktree half. ## Verification `RUST_LOG=worktrunk=debug WORKTRUNK_PICKER_DRY_RUN=1 wt -C <picker-test> switch` against the `wt-perf setup picker-test` repo shows exactly one `git worktree list --porcelain` subprocess per invocation (1 `wt-trace` record, 1 spawn debug line). No behavior change — pure doc-comment deletion (9 lines). ## Test plan - [x] `pre-commit run --files src/commands/picker/mod.rs` — passes - [x] `cargo check` — passes - [x] Empirical: 1 `git worktree list --porcelain` subprocess per `wt switch` > _This was written by Claude Code on behalf of Maximilian Roos_ 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.
Expands the picker and collect module docstrings with measured phase timings, startup flow documentation, and trace instrumentation points. This makes it easier to profile startup performance and understand where time goes in both
wt listandwt switch.Changes:
collect/mod.rswith representative medians from the dev repopicker/mod.rsmodule docstring with startup flow sequence, phase timing table, and reproducing instructionstrace_instantcalls at key picker phases (started, config resolved, layout detected, skeleton rendered)