perf(server): checkpoint capture no longer walks every reflog in the repository #41177
Mergedjuliusmarmingemerged 2 commits into
main fromrefs/pull/41177/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- @@ -1506,0 +1582,21 @@1582+ });1583+1584+ const reflogWalks: string[] = [];1585+ const queryDriver = yield* GitVcsDriver.makeVcsDriverShape().pipe(1586+ Effect.provideService(VcsProcess.VcsProcess, {1587+ run: (input) => {1588+ if (input.args.includes("--walk-reflogs")) {1589+ reflogWalks.push([...input.args, input.stdin ?? ""].join(" "));1590+ }1591+ return liveProcess.run(input);1592+ },1593+ }),1594+ );1595+ assert.deepEqual(1596+ yield* queryDriver.checkpoints.listAuthoredPaths({ cwd, fromCheckpointRef, toCheckpointRef }),1597+ new Set(["own.txt", "picked.txt", "local.txt"]),1598+ );1599+ assert.isNotEmpty(reflogWalks);1600+ for (const walk of reflogWalks) {1601+ assert.notInclude(walk, "unrelated");1602+ if (walk.includes("--all")) assert.include(walk, "--exclude=refs/*");@@ -2368,3 +2369,6 @@23682369 outputMode: "error",23692370 }).pipe(Effect.map((result) => result.stdout.split("\0")));237023712372+ // Refs under `namespace` that contain any of `commits`. Only the oldest commits of the set2373+ // are passed on, since a ref containing a descendant also contains its ancestors.2374+ const listRefsContaining = Effect.fnUntraced(function* (@@ -2368,3 +2369,20 @@23682369 outputMode: "error",23692370 }).pipe(Effect.map((result) => result.stdout.split("\0")));237023712372+ // Refs under `namespace` that contain any of `commits`. Only the oldest commits of the set2373+ // are passed on, since a ref containing a descendant also contains its ancestors.2374+ const listRefsContaining = Effect.fnUntraced(function* (2375+ commits: ReadonlySet<string>,2376+ namespace: string,2377+ ) {2378+ const roots = (yield* listLines(2379+ ["rev-list", "--no-walk=unsorted", "--parents", "--stdin"],2380+ `${[...commits].join("\n")}\n`,2381+ )).flatMap((line) => {2382+ const [commit = "", ...parents] = line.split(" ");2383+ return parents.some((parent) => commits.has(parent)) ? [] : [commit];2384+ });2385+ const refs = yield* Effect.forEach(Arr.chunksOf(roots, 256), (chunk) =>2386+ listLines([2387+ "for-each-ref",2388+ "--format=%(refname)",@@ -2370,0 +2388,21 @@2388+ "--format=%(refname)",2389+ ...chunk.flatMap((commit) => ["--contains", commit]),2390+ namespace,2391+ ]),2392+ );2393+ return [...new Set(refs.flat())];2394+ });2395+ // With --walk-reflogs, --max-age compares each entry's own time; --since would guess at a2396+ // date and reads a timestamp before 1973 as now. Walking many reflogs at once slows down2397+ // quadratically with the refs passed: --all took 40 s in a repository with 29k refs.2398+ const walkReflogs = (revisionArgs: ReadonlyArray<string>, refs: ReadonlyArray<string>) =>2399+ listLines(2400+ [2401+ "log",2402+ "--walk-reflogs",2403+ ...revisionArgs,2404+ `--max-age=${capturedAt}`,2405+ "--format=%H %gD %gs",2406+ "--stdin",2407+ ],2408+ `${refs.join("\n")}\n`,
Pushedd3a1940
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
juliusmarminge merged this8708a29
juliusmarminge closed this
Sign in to join this conversation.
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Other scenarios#
All 64 scenario measurements match
main.All 64 scenario measurements
short turn resumeWebSocket decodedshort turn resumeWebSocket messageslong turn running, cold openHTTP decodedlong turn running, cold openrowslong turn running, history pageHTTP decodedlong turn running, history pagerowslong turn finished, cold openHTTP decodedlong turn finished, cold openrowslong turn finished, socket cold openWebSocket decodedlong turn finished, socket cold openWebSocket messageslong turn finished, socket cold openrowslong turn finished, work pageHTTP decodedlong turn finished, work pagerowsidle thread resumeWebSocket decodedidle thread resumeWebSocket messagesfleet shell snapshotHTTP decodedfleet shell snapshotrowsfleet shell subscribeWebSocket decodedfleet shell subscribeWebSocket messagesfleet shell resume checkHTTP decodedfleet shell resume checkrowsstale shell reloadHTTP decodedstale shell reloadrowsstale shell resumeWebSocket decodedstale shell resumeWebSocket messagesstale todo list cold openHTTP decodedstale todo list cold openrowsstale todo list cold opennodesstale todo list cold opensubagentsstale todo list cold openplansstale todo list cold openproviderTurnsstale todo list cold opencheckpointsshort turn resumeWebSocket decodedshort turn resumeWebSocket messageslong turn running, cold openHTTP decodedlong turn running, cold openrowslong turn running, history pageHTTP decodedlong turn running, history pagerowslong turn finished, cold openHTTP decodedlong turn finished, cold openrowslong turn finished, socket cold openWebSocket decodedlong turn finished, socket cold openWebSocket messageslong turn finished, socket cold openrowslong turn finished, work pageHTTP decodedlong turn finished, work pagerowsidle thread resumeWebSocket decodedidle thread resumeWebSocket messagesfleet shell snapshotHTTP decodedfleet shell snapshotrowsfleet shell subscribeWebSocket decodedfleet shell subscribeWebSocket messagesfleet shell resume checkHTTP decodedfleet shell resume checkrowsstale shell reloadHTTP decodedstale shell reloadrowsstale shell resumeWebSocket decodedstale shell resumeWebSocket messagesstale todo list cold openHTTP decodedstale todo list cold openrowsstale todo list cold opennodesstale todo list cold opensubagentsstale todo list cold openplansstale todo list cold openproviderTurnsstale todo list cold opencheckpointsBaseline:
2808e87· PR result:d3a1940· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.