Skip to content

Creating a worktree thread on Windows takes 29 s for this repo and 118 s for a 191k-file repo (9 s and 39 s in WSL) #36674

Open

Description

@juliusmarminge

Problem

Starting a thread in a new worktree takes 29 s on Windows for this repository and 118 s for a 191k-file repository. The same machine does it in 9 s and 39 s inside WSL. Removing a worktree takes 11 to 15 s on Windows and under half a second in WSL.

Numbers

Windows Server 2025, 4 vCPU (Xeon Platinum 8370C), 16 GB, NTFS, Git for Windows 2.56.1, Node 26.13.1, Defender on with default settings and no exclusions, commit ca6e09c. The Linux baseline is WSL2 Ubuntu 24.04 (ext4, git 2.43) on the same machine.

Through the app (t3 thread start <project> "msg" --worktree HEAD --branch <name> --wait against the dev server with the Replay provider; the time includes one replayed turn of about 8 s):

Repository Windows WSL
this repo (32,168 files) 29.3 s 9.3 s
llvm-project, depth 1 (191,083 files) 117.9 s 39.2 s

The GitVcsDriver.createWorktree span for llvm-project was 97.2 s on Windows (79.8 s with Defender real-time scanning off) and 24.2 s in WSL.

Git alone on this repository, median of 3:

worktree add, checkout.workers=1 worktree add, checkout.workers=0 (what the server passes) worktree remove --force
NTFS, Defender default 35.0 s 22.3 s 10.8 to 14.7 s
NTFS, Defender real-time off 28.3 s 21.0 s 9.1 to 13.4 s
Dev Drive (ReFS), Defender default 16.5 s 10.7 s 8.6 to 10.5 s
WSL ext4 4.6 s 3.3 s 0.4 to 0.5 s

core.fsync=none made no difference.

Cause

The time is git worktree add writing every tracked file. NTFS creates small files slowly: creating 2,000 2 KB files from Node took 1,238 ms on NTFS and 199 ms on ext4 on this machine, and deleting them 204 ms against 31 ms. Defender accounts for about a fifth of it at most; the rest remains with scanning off.

createWorktree in apps/server/src/vcs/GitVcsDriverCore.ts already asks for parallel checkout (checkout.workers=0), which is worth 35 s to 22 s here. The fast path that avoids writing files, the checkout cache with a copy-on-write clone, exists only on macOS: apps/server/src/vcs/CheckoutCloner.ts returns undefined on every platform but darwin. Windows has block cloning on ReFS and Dev Drive volumes (and none on NTFS), which is why the Dev Drive row is included: a plain checkout there is already twice as fast, before any cloning.

Reproduce on Windows

git clone https://github.com/pingdotgg/t3code C:\src\t3code; cd C:\src\t3code
1..3 | % {
  $add = Measure-Command { git -c checkout.workers=0 worktree add --detach ..\wt-bench HEAD 2>$null }
  $rm  = Measure-Command { git worktree remove --force ..\wt-bench }
  "add {0:n1} s   remove {1:n1} s" -f $add.TotalSeconds, $rm.TotalSeconds
}

Run the same three lines in a clone inside WSL (~/t3code, not /mnt/c) for the baseline. In the app: vp run dev, then node apps/server/src/bin.ts thread start <project path> "hello" --worktree HEAD --branch bench-1 --wait --base-dir <the dev T3 home> and read the GitVcsDriver.createWorktree span in userdata/logs/server.trace.ndjson.

Measured and written by Claude Fable 5.2 in Claude Code (T3 Code).

Activity

  1. juliusmarminge commented on Nov 14, 2026

    @juliusmarminge
    MemberAuthor

    Thanks for writing this up. It asks for new behaviour rather than reporting a defect, so it does not belong in the bug tracker and I'm closing it as not planned here. Feature ideas are discussed in Discussions: please post it there.

  2. juliusmarminge commented on Nov 15, 2026

    @juliusmarminge
    MemberAuthor

    New measurement for this issue: adopting a checkout that was prepared ahead of time, instead of creating one when the thread starts.

    The cost on Windows is creating 32,000 files, and nothing made that faster (Defender off, core.fsync=none, checkout.workers). So the remaining option is to not do it while the user waits. macOS already avoids it by cloning a cached checkout (worktreeCheckoutCache.ts, #32927); CheckoutCloner.ts returns nothing on Windows because NTFS has no clone call. A spare that is handed over whole needs no clone: the thread takes the spare, and a replacement is built in the background.

    What that costs at the moment the thread starts, on this repository (32,321 tracked files), three runs each:

    Windows (NTFS) WSL (ext4), same machine
    git worktree add -b <branch> <dir> HEAD (today) 30.4, 30.7, 33.0 s 4.5, 4.5, 6.1 s
    Spare worktree already at the wanted commit: git switch -c <branch> 123, 125, 126 ms 5, 5, 17 ms
    Spare worktree 77 commits behind (235 files differ): git switch -c <branch> <base> 1.36, 1.60, 1.67 s 0.65, 0.93, 0.95 s
    git status --porcelain in the adopted worktree afterwards 360 to 652 ms 443 to 642 ms

    The spare was made with git worktree add --detach <dir> <commit> and that time is not counted, since it would happen in the background. The status check after adopting came back clean in every run.

    Windows Server 2025, 4 vCPU (Xeon Platinum 8473C), 16 GB, NTFS, Git for Windows 2.56.1, Defender on with default settings, commit a62bc81.

    Not measured: running the project's setup script in the spare as well. If the spare is created at the path the thread will use, installed dependencies would not need to move either, but I did not test that.

  3. juliusmarminge commented on Nov 19, 2026

    @juliusmarminge
    MemberAuthor

    #38810 makes the Labs setting Fast worktree checkout available on Windows by moving a prepared checkout into the new worktree. Measured on Windows Server 2025 with Defender on and no exclusions, on this repository: worktree creation went from 20 to 40 s to 2.3 to 2.7 s (4.5 s when the prepared checkout is 80 commits behind). The first worktree of a repository still takes the full time, and the next prepared checkout is written in the background in 22 to 30 s.

    Measured and written by Claude Fable 5.2 in Claude Code (T3 Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions