Skip to content

[Bug]: t3 serve leaks to ~6 GB RAM, pegs 4+ CPU cores, and wedges :3773 under large thread/worktree history (runaway git/PR sync + StorageCleanup churn) #42557

Backlog

Description

@Cujuju

Environment

  • T3 version: 0.1.12-nightly.20261124.5209 (background service via Windows Scheduled Task / __service-launcher)
  • OS / Hardware: Windows x64, 16 cores / 32 threads, 128 GB RAM (~68 GB free at time of incident)
  • Active workload at time of lockup: Light — 6 idle provider child processes, 23 threads with runs in the last hour (97 in the last 24h), 2 active PR watches

Summary

After ~4.5 hours of uptime, t3.exe serve grew to 5.87 GB working set / 6.26 GB private memory, pegged 9 threads (~4+ CPU cores continuously), and stopped responding on :3773 (local HTTP requests timed out after 4s; relay tunnel logged repeated Incoming request ended abruptly: context canceled). t3 service restart also hung (>45s) waiting on the wedged process and required force-killing t3.exe serve and restarting the scheduled task.

Trace and database inspection indicate the overload is driven by background sync and cleanup loops scaling with accumulated thread/worktree history (especially unsettled delegated child threads and worktrees belonging to settled-but-unarchived threads), rather than simultaneous active runs.

State shape that triggers it

From statev2.sqlite (~11.7 GB + 128 MB WAL) across ~20 git repositories:

  • 4,869 total threads, 4,858 live (only 2 archived, 9 deleted):
    • Unsettled (611): 93 top-level + 518 delegated child threads (595 with a branch, 66 distinct on-disk worktrees). Of the 518 unsettled children, 503 belong to unsettled parents and 471 are >24h old (299 are 1–7d, 170 are 7–30d, 2 >30d). One delegation-heavy repo alone accounts for 54 unsettled top-level threads and 370 unsettled child threads (36 on-disk worktrees).
    • Settled, unarchived (4,248): 938 top-level + 3,310 delegated children (4,054 with a branch, 157 distinct worktrees still on disk).
  • Linked PRs across live threads: 36 open (2 watched), 1,652 merged, 16 closed.
  • Worktrees on disk: ~182 tracked by live threads (+ ~84 untracked/orphaned directories across worktree roots).

Evidence from logs and traces

1. t3 trace summary (21.7 min window right before tracing froze)

server.trace.ndjson was rotating 10 MB files every ~2–3 minutes (~10,200 spans/min):

222105 spans ended over 21.7 min.

span                                             count    /min   p50    p90    max  interrupted  failed
sqlite                                           35893  1657.7   0ms    2ms  526ms            1       0
sql.transaction                                  15295   706.4   3ms    9ms   1.3s            0       0
runGitCommand                                     6424   296.7  51ms   99ms  14.1s           12       6
GitManager.rememberPrLookupGitState               4513   208.4   0ms  101ms  281ms            0       0
ProjectionStore.pendingBackgroundDataByThreadId   3540   163.5   0ms    0ms   73ms            0       0
ServerSecretStore.get                             3228   149.1   0ms    1ms  330ms            0       0
processRunner.runProcessCore                      3119   144.0  60ms  104ms   1.1s            0       0
VcsProcess.spawn                                  2784   128.6  61ms  109ms   1.1s            0       0
VcsProjectConfig.resolveKind                      1600    73.9   2ms    8ms   3.2s            0       0
VcsDriverRegistry.detect                          1599    73.8   5ms  175ms  401ms            0       0
VcsProjectConfig.findConfigPath                   1549    71.5   2ms    8ms   3.2s            0       0

2. Post-restart trace (first 5.2 min on a fresh server)

Immediately after restart, the fresh t3 serve hit 103 distinct git.cwd paths with 1,673 runGitCommand calls (~320/min) and burned 174s CPU in the first 6.5 min:

  • PullRequestSyncReactor: 35 sweeps / 110 sync groups / 882 GitManager.rememberPrLookupGitState calls.
  • Single-span heap growth attributes observed in server.trace.ndjson:
    • ThreadPullRequestServiceV2.synchronize: +229.5 MB (memory.heap_growth_bytes: 229529176)
    • StorageCleanup.cleanCheckpointRefs: +74.6 MB
    • StorageCleanup.readThreads: +67.5 MB
    • PullRequestWatchReactor.sweep: +66.9 MB
    • PullRequestService.canonicalRef: +49.3 MB
    • PullRequestReadCache.pruneExpiredEntryFiles: +41.6 MB
  • Top git.operation counts in those 5.2 min: GitVcsDriver.readConfigValue (271), GitManager.readRemoteUrl (220), StorageCleanup.branchChanged (142), GitManager.branchPullRequest.branchRef (141), GitVcsDriver.resolveDefaultBranchName (117), GitManager.branchPullRequest.remotes (81), GitManager.findPublishedBranchRemote (68), StorageCleanup.localChanges (58).

3. Heap spike, fiber churn, and event-loop stalls before lockup

  • Just before server.trace.ndjson stopped flushing:
    {
      "name": "server.heap.spike",
      "attributes": {
        "heapUsedMb": 432,
        "growthMb": 180,
        "suspects": [
          "StorageCleanup.containsProjectRoot +178 MB",
          "GitWorkflowService.repositoryRoot +173 MB",
          "VcsDriverRegistry.detect +173 MB",
          "VcsProjectConfig.resolveKind +173 MB",
          "VcsProjectConfig.findConfigPath +173 MB",
          "VcsStatusBroadcaster.publishCheckedOutRef +169 MB",
          "VcsStatusBroadcaster.refreshBranchStatusCore +168 MB",
          "VcsStatusBroadcaster.readHeadBranch +168 MB"
        ]
      }
    }
  • Effect fiber IDs in boot-service.log reached #33,451,740 in ~4.5 hours (~2,000 fibers/sec), alongside repeated GitCommandError timeouts:
    GitCommandError: Git command failed in GitManager.branchPullRequest.remotes (<repo-or-worktree-path>): Git command timed out.
        at GitManager.branchPullRequest.remotes
        at GitManager.rememberPrLookupGitState
        at lookupBranchPullRequest
        at branchPullRequest
        at ThreadPullRequestServiceV2.synchronize
        at DrainableWorker.makeDrainableWorker
    
  • event-loop-stalls.ndjson recorded sustained 2–4s stalls at 100% utilization with RSS at 4.8–5.8 GB:
    {"delayMaxMs":4079,"utilization":1,"cpuUserMs":79079,"cpuSystemMs":59531,"majorPageFaults":67715,"rssMb":5502}
  • At lockup, thread sampling over 3s showed 9 threads in t3.exe actively consuming ~12.5 CPU-seconds (~4.2 cores continuously — one main thread at 100% + 8 worker/GC threads) while HTTP requests to :3773 timed out.

Key areas that look worth fixing

  1. PR sync scope & deduplication (PullRequestSyncReactor / ThreadPullRequestServiceV2.synchronize):
    • Finished delegated child threads remain unsettled as long as their parent thread is unsettled, multiplying PR/branch git lookups by 5–10× per thread tree even when idle for days/weeks.
    • Syncing appears to re-run git per thread/worktree rather than deduplicating by (repo, branch) and backing off idle threads.
  2. Storage cleanup memory & scan scope (StorageCleanup.sweep):
  3. Memory retention / fiber leak under sustained VCS polling:
    • Process memory climbs steadily from ~500 MB after restart to >6 GB over ~4.5h while fiber IDs hit tens of millions, eventually starving the event loop.
  4. Resilience of t3 service restart:
    • When t3 serve is event-loop-starved, t3 service restart blocks indefinitely (>45s) instead of timing out graceful shutdown and terminating the wedged child.

(Sanitized event-loop-stalls.ndjson, full t3 trace summary, or path-anonymized server.trace.ndjson extracts available on request.)

Activity

  1. Cujuju commented on Nov 25, 2026

    @Cujuju
    Author

    Note

    🤖 Gemini 4 Neon responding on behalf of Cujuju

    Added a sanitized diagnostics bundle from the incident window (unlisted Gist): https://gist.github.com/Cujuju/504245dc7ee23709758e67c7b01ac41b

    Files included

    • event-loop-stalls.ndjson (109 lines) — Full event-loop stall log including the 2–4s stalls at 100% utilization / 4.8–5.8 GB RSS and the 2932 ms stall immediately before force-restart.
    • trace-summary-200.txt — Output of t3 trace summary --limit 200.
    • boot-service-excerpt.sanitized.log (120 records) — Warnings, errors, fiber-ID progression (#33.4M), GitCommandError timeout stacks, ServerSecretStore.get interrupts, and post-restart recovery output.
    • server-trace-pre-lockup.sanitized.ndjson (22,134 spans, click Raw to download) — Trace slice covering the 01:40:28Z server.heap.spike (+180 MB) and lockup.
    • server-trace-post-restart.sanitized.ndjson (23,757 spans, click Raw to download) — First ~3.5 minutes after a clean restart, which also hit a server.heap.spike 14s after boot (01:49:17Z, heapUsedMb: 262, growthMb: 134, suspects: server.startup.projects.auto-pull +132 MB, StorageCleanup.sweep +128 MB, ThreadPullRequestServiceV2.synchronize +128 MB, ManagedTunnelOrigin.watch +128 MB, autoPullProjects +125 MB, statusDetails +125 MB, refreshStatusUpstreamIfStale +125 MB).

    (Paths are deterministically anonymized to <projects>/repo-NN and <worktrees>/repo-NN/wt-NNN to preserve repo/worktree cardinality; db.query.text is reduced to SQL verb only, span events are stripped, and usernames/IDs/URLs are redacted.)

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