Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): parallelize worktree checkout and narrow the bootstrap fetch #9039

ClosedStiensWout(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/9039/headopened View on GitHub

Creating a worktree thread on a large repository makes the user sit through a slow "Setting up worktree..." step: git worktree add checks the tree out on a single thread, and the "start from origin" bootstrap runs a full git fetch origin (every head plus tags) when the only ref it ever reads is origin/<baseBranch>.

Two changes to the worktree bootstrap path:

  • createWorktree now passes -c checkout.workers=0 (one worker per logical core) to git worktree add, unless the user configured checkout.workers themselves. Raw git benchmarks: 2.2-2.9s to 1.2-1.5s on a 16k-file repo, 12.8-20.3s to 9.4-11.5s on a 150k-file tree.
  • fetchRemote now fetches only the requested base branch with --no-tags, using an explicit refspec parsed the same way resolveRemoteTrackingCommit parses the ref, so the tracking ref resolved next is exactly the one made current. This also fixes the latent case where a base branch naming another remote (upstream/main) fetched origin but resolved upstream/* stale.

End-to-end proof, driven with Playwright against a 129,600-file fixture repo: both sides send the same message at t=0 on the same warm machine, one frame per second. Before needs 19.7s until the worktree is ready; after this commit it takes 11.4s (repeat runs: before 15.9s/17.9s, after 11.7s/11.1s).

worktree creation, before vs after, one frame per second

Verified with vp test run apps/server/src/vcs/GitVcsDriverCore.test.ts (58 passed, including two new narrow-fetch behavior tests) and the bootstrap seam tests in server.test.ts; server typecheck is clean.

Written by Claude Fable 5 via Claude Code.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR changes production worktree bootstrap behavior by enabling parallel checkout by default and narrowing remote fetches to a selected branch. The default behavior change and its effect on existing bootstrap workflows warrant human review despite the focused tests.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).

Sign in to join this conversation.