Skip to content

perf: batch branch commit-message lookups in shell completion#187

Open
tksm wants to merge 1 commit into
k1LoW:mainfrom
tksm:perf/completion
Open

perf: batch branch commit-message lookups in shell completion#187
tksm wants to merge 1 commit into
k1LoW:mainfrom
tksm:perf/completion

Conversation

@tksm
Copy link
Copy Markdown

@tksm tksm commented May 10, 2026

Summary

git wt's shell completion previously forked git log -1 once per branch to fetch each branch's commit subject, which became slow in repositories with many local or remote-tracking branches. This change batches the lookup into a single git for-each-ref call. In a 500-branch reproduction, completion drops from ~2.2s to ~0.12s (~20x faster).

Reproduction

The reproduction below uses local branches only for simplicity. git-wt is the released binary and git-wt-fixed is built from this branch.

tmp=$(mktemp -d) && cd "$tmp"
git init -q && git commit -q --allow-empty -m init
for i in $(seq 1 500); do git branch "b-$i"; done

time git-wt __complete "" >/dev/null
Completion ended with directive: ShellCompDirectiveNoFileComp
git-wt __complete "" > /dev/null  1.01s user 0.88s system 84% cpu 2.227 total

With the fix applied:

time git-wt-fixed __complete "" >/dev/null
Completion ended with directive: ShellCompDirectiveNoFileComp
git-wt-fixed __complete "" > /dev/null  0.05s user 0.06s system 87% cpu 0.119 total

I confirmed the completion output is identical before/after.

diff <(git-wt __complete "" 2>/dev/null) <(git-wt-fixed __complete "" 2>/dev/null)
# (no output → outputs are identical)

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.

1 participant