Skip to content

perf(server): unqueue read-only git calls and bound worktree add - #1727

Merged
chuks-qua merged 1 commit into
mainfrom
perf/git-read-only-queue-lane
Sep 21, 2026
Merged

chuks-qua merged 1 commit into
mainfrom
perf/git-read-only-queue-lane

Conversation

@chuks-qua

@chuks-qua chuks-qua commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

What

Previously every git invocation was serialised per repository, and git worktree add ran with timeout: 0 (no timeout). A slow or hung worktree add therefore stalled every other git call on that repo — branch probes, worktree list, status, diffs — and could wedge thread creation indefinitely.

Now:

  • worktree add is bounded at 120s (WORKTREE_ADD_TIMEOUT_MS).
  • RealGitExecutor classifies each command: mutating commands keep the per-repo serialisation queue (git lockfiles make concurrent worktree add/checkout/branch mutations race); read-only commands (rev-parse, worktree list, status, diff, log, ls-files, cat-file, show-ref, merge-base, branch/remote/config/symbolic-ref read forms, and friends) bypass the queue entirely.
  • Unknown commands default to serialised, so a missed classification can only be slow, never racy.
  • Read-only commands no longer invalidate the rev-parse cache; only mutations do.

Verified: 11/11 executor tests, 117/117 tests under projects/git + projects/worktrees, tsc --noEmit clean, oxlint clean on touched files.

Why

Worktree-backed thread creation was failing or hanging when a worktree add stalled, and every subsequent git read on that repo queued behind it. Users benefit: thread creation fails fast instead of hanging, and repo reads stay responsive while worktrees are provisioned.

Review Notes

git status is classified read-only: its index stat-cache refresh uses git's optional-lock mechanism, so it degrades gracefully under a concurrent mutation instead of blocking or failing. Mixed subcommands are matched by arg shape (worktree list, branch listing forms, remote get-url, config --get*, symbolic-ref --short); mutating forms stay queued.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

git worktree add previously ran with no timeout, so a hung add stalled the
RPC forever. Bound it at 120s.

All git calls were also serialised per repo, so a slow mutation blocked
every read on that repo (worktree list, branch probes, status, diffs).
Mutating commands keep the per-repo queue; read-only commands now run
unqueued.
@chuks-qua
chuks-qua merged commit f78c5d3 into main Sep 21, 2026
6 checks passed
@chuks-qua
chuks-qua deleted the perf/git-read-only-queue-lane branch September 21, 2026 20:53
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