Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): checkpoint captures run fewer git commands #42473

Mergedjuliusmarmingemerged 3 commits intomain fromrefs/pull/42473/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Problem

A turn-end checkpoint capture runs while the run holds one of the 4 EffectWorker slots, so under many concurrent working threads new turns queue behind captures. A typical root capture ran 15 git processes, and the previous checkpoint was resolved five times along the way: the capture's own log --no-walk, the summary's rev-parse (hasCheckpointRef), then resolveTurnStart once in diffCheckpoints and again in listAuthoredPaths, plus a log --format=%ct %P for the heads. A turn that changed nothing ran all 15, including an empty numstat diff.

Fix

  • captureCheckpoint now reads the previous checkpoint once, whether or not a branch switch is being replayed. It returns a VcsCheckpointRange built from what it already knows: where the turn started (the previous commit or its branch-switch turn start), the new commit, the start's commit time, both first-parent heads, and whether the new tree equals the start's tree.
  • CheckpointService.captureSummarized uses the range in place of hasCheckpointRef. It also passes the range to diffCheckpoints and listAuthoredPaths, which then skip resolveTurnStart and the heads log. Callers that pass no range, like CheckpointDiffQuery and the clean-HEAD repository path, behave exactly as before.
  • No-change early exit: when the tree equals the start's tree, the diff and authored-paths reads are skipped and the checkpoint records files: [], as before.
  • Kept on purpose: the no-change path still runs commit-tree and update-ref. Every turn keeps its own ordinal ref, which restore, rollback, stale-ref cleanup and turn diffs depend on. A fresh commit also keeps that ref's committer time. Pointing the ref at the previous commit would back-date the next turn's start: listAuthoredPaths reads "own commits" as those newer than the start's %ct, so commits made elsewhere during the empty turn would be credited to the next one. The saving would be one process.
  • Old Git (before 2.31) does not return HEAD from the combined rev-parse. On that path the parent is resolved explicitly, and only when a range is returned.

Git processes per root capture

Counted in a new real-git test (CheckpointCaptureService.test.ts, "captures a turn without re-reading the previous checkpoint"). The test wraps VcsProcess and counts commands from after the turn's edits.

TurnBeforeAfter
Edits files, HEAD unchanged1511
Changed nothing1510
Agent committed (HEAD moved)4 more than afterrev-parse and 3 logs fewer

The test fails on main (it reports the extra rev-parse, log, log, log) and passes with this change.

Verified: the src/orchestration-v2, src/checkpointing and src/vcs suites pass (140 files, 4150 tests), and so do typecheck and vp run check:changed.

🤖 Generated with Claude Code (Claude Opus 5.5, T3 Code)

    1. Pushed6870a8a

    2. juliusmarminge merged this4248955

    3. juliusmarminge closed this

Sign in to join this conversation.