Repository navigation
perf(server): unqueue read-only git calls and bound worktree add - #1727
Merged
Merged
Conversation
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.
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.
What
Previously every git invocation was serialised per repository, and
git worktree addran withtimeout: 0(no timeout). A slow or hungworktree addtherefore stalled every other git call on that repo — branch probes,worktree list, status, diffs — and could wedge thread creation indefinitely.Now:
worktree addis bounded at 120s (WORKTREE_ADD_TIMEOUT_MS).RealGitExecutorclassifies each command: mutating commands keep the per-repo serialisation queue (git lockfiles make concurrentworktree add/checkout/branchmutations race); read-only commands (rev-parse,worktree list,status,diff,log,ls-files,cat-file,show-ref,merge-base,branch/remote/config/symbolic-refread forms, and friends) bypass the queue entirely.Verified: 11/11 executor tests, 117/117 tests under
projects/git+projects/worktrees,tsc --noEmitclean, oxlint clean on touched files.Why
Worktree-backed thread creation was failing or hanging when a
worktree addstalled, 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 statusis 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,branchlisting forms,remote get-url,config --get*,symbolic-ref --short); mutating forms stay queued.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.