[Bug]: vcs.refreshStatus takes ~25s on branches with a large diff (--minimal in change-totals diff) #21858
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/server
Steps to reproduce#
- Open a thread on a worktree whose branch differs a lot from its base (about 1,500 files, +222k / −184k lines, e.g. a long-lived feature branch merged in).
- Trigger a status refresh, or let a run finish.
- The "Some requests are slow" toast appears:
vcs.refreshStatuswaiting longer than 15s.
Expected behavior#
vcs.refreshStatus finishes in about the time of the remote fetch (~3s), as it does on other worktrees.
Actual behavior#
Every refresh on that worktree takes 20–25s. Almost all of it is the change-totals step (GitVcsDriver.readBranchChangeTotals), which runs git diff with --minimal. Without --minimal, the same --numstat diff takes under half a second and gives the same output.
Timing the command by hand on the same branch:
| Command | Wall time | Output |
|---|---|---|
git diff --find-renames --no-color --no-ext-diff --no-textconv --minimal --numstat -z <merge-base> -- | 20.9s (19.0s user CPU) | 78,643 bytes |
Same, without --minimal | 0.49s | 78,644 bytes |
The output differs by 1 byte: --minimal changes no file's add/delete count by more than a line.
Related: the same 21s diff also runs from RunFinalizationService.finalize while user-triggered refreshes for the same worktree are in flight, and each call recomputes it from scratch.
Suggested fixes:
- Drop
--minimalfrom the diff used for--numstatchange totals. Exact-minimal hunks don't matter for line counts. - Deduplicate or cache in-flight
readBranchChangeTotalscalls per worktree andHEAD/merge-base pair, so concurrent refreshes share one result.
Impact#
Major degradation or frequent failure
Version or commit#
0.0.46-nightly.20261013.3066
Environment#
macOS (Darwin 25.6), T3 Code Desktop (Nightly), git 2.53.0
Logs or stack traces#
From ws.rpc.vcs.refreshStatus server traces:
- 3 consecutive refreshes took 22,421ms, 25,469ms and 25,464ms. All succeeded, with no errors.
- Span chain:
VcsStatusBroadcaster.refreshStatus→localStatus→readLocalStatus→statusDetailsLocal→readStatusDetailsLocal→readBranchChangeTotals→GitVcsDriver.readBranchChangeTotals/runGitCommand, at 20.9–21.2s. - Every refresh over 5s was this one step on this one branch. On other worktrees the same step takes 10–209ms. Remote fetch adds about 3s;
git statustakes about 55ms. RunFinalizationService.finalizeran the same 21s diff at 14:59:32 while user-triggered refreshes started at 14:59:22 and 14:59:48 were in flight.
Screenshots, recordings, or supporting files#
No response
Workaround#
None in the app. Comparing the branch against a closer base makes the diff small (2 files, +155 lines here), but I found no setting to change the comparison base.
juliusmarminge added labelsaccepted
juliusmarminge added labelsbug
juliusmarminge added labelsvia-triage
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Note
Grok responding on behalf of Julius.
Thanks for timing both versions of the command. Current main matches what you describe.
The Changes totals run
git diff --numstatwith the same shared arguments as the review diff, and those include--minimal(apps/server/src/vcs/GitVcsDriverCore.ts:70-78,:2799-2808). Nothing caches the totals, so every refresh and every run finalization computes them again. Your timings put almost all of the time in--minimal.Accepting the
--minimalpart as a bug. Sharing one result between overlapping refreshes is already tracked in #7076, so that half belongs there.