Repository navigation
Description
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
- On Windows, have one project whose project-root threads (no worktree) share a few branches. Here: 109 threads on one branch (97 settled), about 8 branches overall. The install has 23 projects, 1741 live threads and about 70 git working dirs (projects plus kept worktrees).
- Start T3 Code (or restart it).
- Watch Task Manager, or count
runGitCommandspans inserver.trace.ndjson, for the first 2 minutes.
Expected behavior
A start costs about one branch PR lookup per (repo, branch). Settled threads don't trigger lookups at start. Git process count stays bounded, so the machine stays usable.
Actual behavior
CPU is pegged and Git for Windows is the top process in Task Manager. It stops as soon as T3 is closed. No agent turn was running: every active thread had reached end_turn.
From server.trace.ndjson*:
- 1629
runGitCommandspans in about 20 minutes: 555 in the first minute after start, 760 in the second, then 7-25 per minute. - The first start after updating was worse: 1849 git and 291 PR lookups in 3 minutes, peaking at 953 git and 180 lookups in one minute.
- Up to 14 git processes at once. Under that load a single
git rev-parseorgit worktree listtook 50-135 s. - Git calls by entry point:
branchPullRequest675,server.startup287,ws.rpc.subscribeVcsStatus182,ws.rpc.vcs.refreshStatus146,StorageCleanup.sweep94. - The repo from step 1 got 67
branchPullRequestlookups in 2 minutes, which spawned 760 git processes, even though its threads are on only about 8 branches. Up to 21 of those lookups ran on that one repo at the same time, so they aren't coalesced. - Each lookup ran 5 git processes on average (between 1 and 9). Lookups took 7.6 s on average and up to 317 s.
- Each lookup also calls the forge (the remote is Bitbucket Data Center): 102
BitbucketApi.listPullRequestscalls in the same window. - Most lookups are root spans at start. The rest come from
ThreadSettlementServiceV2.sweepandThreadPullRequestServiceV2.synchronize.
So branch PR lookups seem to run per thread instead of per (cwd, branch), and settled threads still trigger them.
Related, not duplicates:
- Each branch pull-request lookup on Windows starts 14 git processes, and 5 of them re-read what the same lookup already read: 42 git at every server start for 3 branches #40089 / perf(server): branch PR lookups start 9 git processes instead of 14 #40153 cut git processes per lookup (14 -> 9). This issue is about how many lookups run.
- Long-running multi-agent hosts: state DB growth, git polling of finished worktrees #40677 covers git polling of finished worktrees.
- [Bug]: Spawning git forks the whole server process, taking a median 8 to 32 ms from fork to exec under agent load #31422 covers git spawn cost.
Impact
Major degradation or frequent failure
Version or commit
0.1.12-nightly.20261122.5085 (desktop, nightly channel). Updated that morning from 0.1.11-nightly.20261118.4877.
Environment
Windows 11, 12 cores / 24 threads, 48 GB RAM (not a slow machine), third-party endpoint protection (EDR) scanning every new process, T3 Code Desktop (nightly), git 2.55.0.windows.3, Bitbucket Data Center remote, Claude provider
Logs or stack traces
# runGitCommand / branchPullRequest spans per minute
# 0.1.11-nightly.20261118.4877, steady state (no server start within the retained logs)
~40-220 git/min, 0-7 PR lookups/min
# 0.1.12-nightly.20261122.5085, first start after the update
start+0: 476 git / 65 lookups +1: 420 / 46 +2: 953 / 180 +3: 132 / 3
# 0.1.12-nightly.20261122.5085, restart 26 min later
start+0: 555 git / 73 lookups +1: 760 / 58 +2: 2 / 0
# slowest single git calls (parent span -> duration)
GitVcsDriver.fetchRemoteForStatus 135 s
GitWorkflowService.currentBranch 101 s
GitWorkflowService.currentBranch 100 s
GitWorkflowService.currentBranch 88 s
GitVcsDriver.readWorktreeBranchPaths 72 s
# top call chains into runGitCommand
121 GitManager.readRemoteUrl <- resolveRemoteRepositoryContext <- resolveBranchHeadContext <- resolveLookupHeadContext <- lookupBranchPullRequest <- branchPullRequest
118 GitManager.branchPullRequest.branchRef <- GitManager.rememberPrLookupGitState <- lookupBranchPullRequest <- branchPullRequest
117 GitVcsDriver.readConfigValue <- resolveBranchHeadContext <- resolveLookupHeadContext <- lookupBranchPullRequest <- branchPullRequestWorkaround
None found except closing T3.
Activity
OhadC commentedon Nov 22, 2026
Source check against
v0.1.12-nightly.20261122.5085(done during at3 triagesession on the same machine):Correction to the original report: the settlement sweep already groups lookups by (cwd, branch).
ThreadSettlementService.ts:500-518(lookupKey/Map.groupBy) builds one group per branch-or-linked-PR key. So the per-thread fan-out described above comes from otherbranchPullRequestcallers. Candidates:ThreadPullRequestService.ts(lines 184, 314, 406)ws.rpc.subscribeVcsStatus/ws.rpc.vcs.refreshStatusstatus pathsstorageCleanup.ts:1702I haven't confirmed which one dominates.
Why concurrent lookups on one repo don't collapse (
apps/server/src/git/GitManager.ts):branchPullRequest(L3335) is limited only by a server-wide semaphore of 4 (BRANCH_PR_LOOKUP_CONCURRENCY, L228). Nothing merges callers asking about the same (cwd, branch) at the same time. Each one runs its own lookup.rememberPrLookupGitState(L3014) caches git reads for 5 min, but has no in-flight dedup: N simultaneous misses on the same key run git N times. Any call withfreshGitState: trueskips the cache entirely.settledPrLookupByBranchKey(L3052), the "closed/merged PR is final" memo, lives only in memory, so it's empty after every server start. On the first call after start, every branch with a closed or merged PR does a second lookup withfreshGitState: true(L3369). This fits the burst being concentrated in the first 1–3 minutes after start, and being worst right after the update restart.Possible directions:
branchPullRequestcalls into one per (cwd, branch).rememberPrLookupGitState.Related: #28196. The trace volume on this machine (~10 MB per 5 min) matches it.
Also, the
bug/needs-triagelabels from the bug-report form didn't get applied to this issue.Produced by Claude Code (Claude Opus 5.5) via
t3 triage.OhadC commentedon Nov 22, 2026
Closing: the sustained high CPU in this report wasn't caused by T3.
While these traces were recorded, an agent session on the same machine was deliberately running a CPU stress test for an unrelated flaky-test investigation: a busy-loop script with 40-72 worker threads on a 24-thread CPU, plus looping vitest runs through Git for Windows'
bash.exe. That's why CPU was pegged, why "Git for Windows" showed up in Task Manager, and why individual git calls took 50-135 s. The timings above are confounded and shouldn't be used.A clean restart with no agent load: T3 server used up to ~3.7 cores and up to 9
git.exefor about 45 s after start (23 projects, ~1,740 threads), then went idle. That startup cost is small, so I'm not pursuing it here.The source notes in my earlier comment (no in-flight dedup in
branchPullRequest/rememberPrLookupGitState, closed-PR memo not kept across restarts) may still be worth a look as a startup-cost optimization, but they don't cause what this issue describes.Produced by Claude Code (Claude Opus 5.5) via
t3 triage.