perf: parallelize picker annotations and add spinners for slow git ops#21
Merged
Merged
Conversation
The interactive picker and `wt -l` computed each worktree's status (`git status` + `git rev-list`) serially before fzf appeared, blocking on repos with many worktrees. Split the per-worktree decoration into annotate_one and fan it out with `xargs -P`, streaming rows into fzf as they finish. Branch and path are passed as NUL-delimited args so values with spaces survive and the tab separator can't be mangled. Slow git operations no longer look frozen: a spinner runs while `git worktree remove`, `git worktree add`, and `wt pr` (fetch + checkout) execute. Falls back to a plain run with a one-line breadcrumb when output isn't a terminal, keeping stdout reserved for the result path. Bump version to 0.6.1. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Why
Two issues with the recent additions to
wt:wt -l) felt slow on repos with many worktrees.The picker's cost was structural, not the language:
annotate_worktreesrangit status+git rev-listserially, once per worktree, before fzf even appeared.What changed
Parallel + streaming picker
annotate_one, fanned out withxargs -Pacross all cores, streaming rows into fzf as they finish.N × git statusserial → ~1×wall-clock, and fzf paints immediately.-0 -n2) so names/paths with spaces survive and the tab separator can't be mangled (this had also been silently breaking the!dirty flag).Spinners for slow git operations
git worktree remove,git worktree add, andwt pr(network fetch + checkout) execute.wt: <action>...breadcrumb. stdout stays reserved for the result path; the cursor is restored on Ctrl-C; exit codes propagate unchanged.Version bumped to 0.6.1; CHANGELOG updated.
Note on stack
I looked into rewriting in Go/Rust for speed — it wouldn't help. The time is git stat-ing files, not Bash (measured startup: 0.002s). A port shelling out to git the same way would be just as slow. The only real reason to switch would be single-binary distribution, which isn't what these issues were about.
Verification
shellcheckclean.*/!/↑↓flags, spaced base-dir paths render as one field, create emits only the path on stdout, TTY spinner animates + cleans up.🤖 Generated with Claude Code