Description
What is slow
A user types a commit message and clicks Commit (git.runStackedAction with action: "commit" and commitMessage). No message has to be generated. The server still prepares a full temporary commit context first. It copies the index into a temp directory, expands it, runs git add -A into it, checks for conflicts, and lists the staged names. All of that only tells it whether anything is to be committed. Then commit stages the whole worktree again into the real index and commits. On a large repository the user waits for two whole-worktree staging passes.
Measured
- Windows Server 2025, 4 vCPU, 16 GB, Defender on. Commit
511447a9f2, server from source. - A clone of this repository (32,168 files, index 4.5 MB), no remote, branch
feature-5, withuser.name/user.emailset. Before each run, 3 tracked files get a line appended. - 6 commits sent over the app's own WebSocket from a paired page:
| median (range) | |
|---|---|
| click to result | 2,194 ms (2,164-2,443) |
runStackedAction span |
2,188 ms |
statusDetails (initial status) |
607 ms |
prepareCommitContext |
680 ms (662-705, n=7) |
commit |
812 ms |
| git processes per commit | 20 |
prepareCommitContextruns 6 git:rev-parse --git-path index --git-path objects,count-objects -v,update-index --no-split-index(~60 ms),add -Ainto the temp index (~275 ms),diff --cached --diff-filter=U(~165 ms), anddiff --cached --name-status(~60 ms). It also copies the 4.5 MB index.committhen runscommit.unmergedPaths(~165 ms) andcommit.addAll(~275 ms) again on the real index, followed bycommitandrev-parse HEAD.GitVcsDriver.commit.addAllandGitVcsDriver.commit.unmergedPathsappear twice in every commit (6/6).
How to measure it again
- Check out the commit,
vp i,cd apps/web && vp build.git clone --local <a t3code checkout> p5,git remote remove origin,git checkout -b feature-5,git config user.name perf,git config user.email perf@example.com. - From
apps/server: startT3CODE_DEV_SEED=0 node src/bin.ts serve --base-dir <home> --port 4800 --host 127.0.0.1(production build) andnode src/bin.ts project add <p5> --base-dir <home>. Mint a pairing URL withnode src/bin.ts pair --ttl 1h --base-dir <home>and set its host to127.0.0.1:4800. node gitact.cjs <playwright dir> <pairUrl> <p5> 6 commit out.json, thenV=1 node under.cjs runStackedAction <home>/userdata/logs/server.trace.ndjson*.
// gitact.cjs <playwrightDir> <pairUrl> <repoDir> <runs> <action> <out.json>: per run, append to 3 tracked files, then send
// git.runStackedAction over the page's own WebSocket with a commit message (no generation). Records wall time and progress events.
const [pw, pairUrl, repo, runs, action, out] = process.argv.slice(2); const { chromium } = require(pw); const fs = require("fs"); const path = require("path");
(async () => { const b = await chromium.launch(); const p = await (await b.newContext()).newPage();
await p.addInitScript(() => { const O = window.WebSocket; window.__ws = []; window.WebSocket = class extends O { constructor(...a) { super(...a); if (String(a[0]).includes("/ws")) window.__ws.push(this); } }; });
await p.goto(pairUrl); await p.waitForTimeout(10000); const res = [];
for (let i = 0; i < +runs; i++) {
for (const f of ["README.md", "package.json", "AGENTS.md"]) fs.appendFileSync(path.join(repo, f), `\n${action} ${i} ${Date.now()}\n`);
await p.waitForTimeout(4000);
const r = await p.evaluate(async ({ cwd, i, action }) => { const ws = window.__ws.filter((w) => w.readyState === 1).at(-1); const id = String(900000000 + i);
return await new Promise((resolve) => { const t0 = performance.now(); const chunks = [];
const on = (ev) => { let ms; try { ms = [].concat(JSON.parse(ev.data)); } catch { return; }
for (const m of ms) { if (String(m.requestId) !== id) continue;
if (m._tag === "Chunk") { ws.send(JSON.stringify({ _tag: "Ack", requestId: id })); for (const v of m.values) chunks.push([Math.round(performance.now() - t0), v.kind, v.phase || ""]); }
if (m._tag === "Exit") { ws.removeEventListener("message", on); resolve({ ms: Math.round(performance.now() - t0), exit: m.exit._tag, chunks }); } } };
ws.addEventListener("message", on);
ws.send(JSON.stringify({ _tag: "Request", id, tag: "git.runStackedAction", payload: { actionId: "perf-" + Date.now(), cwd, action, commitMessage: `perf ${action} ${i}` }, headers: [] })); }); }, { cwd: repo, i, action });
r.run = i; console.log(JSON.stringify(r)); res.push(r); await p.waitForTimeout(6000); }
fs.writeFileSync(out, JSON.stringify(res)); await b.close(); })();// under.cjs <spanName> <trace...>: per span of that name, duration and git processes grouped by their operation (V=1 for detail)
const fs=require("fs");const [name,...files]=process.argv.slice(2);const sp=new Map();
for(const f of files)for(const l of fs.readFileSync(f,"utf8").split("\n")){try{const r=JSON.parse(l);if(r.type==="effect-span")sp.set(r.spanId,r)}catch{}}
const kids=new Map();for(const s of sp.values()){const k=kids.get(s.parentSpanId)||[];k.push(s);kids.set(s.parentSpanId,k)}
const desc=s=>{const o=[],q=[s];while(q.length){const x=q.pop();for(const c of kids.get(x.spanId)||[]){o.push(c);q.push(c)}}return o};
const st=s=>Number(BigInt(s.startTimeUnixNano)/1000000n);
for(const s of [...sp.values()].filter(s=>s.name===name).sort((a,b)=>st(a)-st(b))){const g=desc(s).filter(x=>x.name==="runGitCommand");const by={};
for(const x of g){const k=sp.get(x.parentSpanId)?.name||"?";(by[k]=by[k]||[]).push(Math.round(x.durationMs))}
console.log(Math.round(s.durationMs)+"ms","git="+g.length,s.exit?._tag);
if(process.env.V)for(const [k,v] of Object.entries(by))console.log(" ",v.length,k,v.join(","))}Where the time goes
apps/server/src/git/GitManager.ts, runCommitStep calls resolveCommitAndBranchSuggestion. With a custom message, that function still calls gitCore.prepareCommitContext(cwd, filePaths, { includePatch: false }) and only uses the result as a "there are changes" check. In apps/server/src/vcs/GitVcsDriverCore.ts, prepareCommitContext builds a temp index and object directory, copies and expands the index, runs stageCommitChanges into it (add -A and the unmerged check), then diff --cached --name-status. Next, commit runs stageCommitChanges again on the real index and commits. runStackedAction has already read statusDetails (607 ms) at that point, and it lists the changed files.
Why it is avoidable
With a supplied message, the throwaway index only answers whether anything would be committed. The initial status already knows that, and the real staging pass that follows recomputes it. The one case it guards, a merge resolved to HEAD's tree, is a cheap MERGE_HEAD check.
What a fix has to show
The same 6 commits before and after, on the same seed:
- Git processes per commit with a typed message drop from 20 to at most 15, and
GitVcsDriver.commit.addAllruns once per commit, from twice. - Click to result drops by about the
prepareCommitContexttime: ~1.5 s, from 2.19 s. - What stays: the initial status read (~0.6 s), one staging pass with its conflict check,
git commitandrev-parse HEAD(~0.8 s). Behaviour must be the same for "nothing to commit", a merge whose result equals HEAD, selected-file (partial) commits, and hooks. Generated messages still need the staged patch, so they are out of scope. - Not counted here: the status refresh after the commit (42 git; the no-remote part is filed separately).
Found by the automated Windows performance sweep on 511447a.
Found by the automated Windows performance sweep on 511447a.
Activity
perf(server): typed-message commits stage the worktree once
Sharad-Patel1 commentedon Nov 22, 2026
Note
Generated by claude-opus-5-5
RESPONDING ON BEHALF OF SHARAD
This can be closed: #40282 (69228fe) fixes it on
main. It first shipped in v0.1.12-nightly.20261121.5051, with no stable release yet. The PR says "Refs" rather than "Fixes", so it didn't close this issue on merge.runCommitStepnow builds the suggestion straight from a typed message and skipsprepareCommitContext.commitstages the real index once (GitVcsDriverCore.ts). It only builds the throwaway index whengit diff --cached --quietshows something already staged, and in the issue's setup nothing is. Nothing to commit still returnsskipped_no_changes, and a merge resolved to HEAD still commits after aMERGE_HEADcheck.The git process count misses the issue's target by one. The fix adds two
git diff --cached --quietchecks (commit.indexChangesandcommit.stagedChanges, 14 and 15 ms here), so a typed commit starts 4 fewer git processes, not 5. Applied to the issue's 20, that would be 16, not "at most 15".commit.addAlldoes run once. I didn't measure on Windows. Two cases still stage twice by design: a commit with changes already staged, and a generated message, which the issue leaves out of scope.The attached script adds one test to
GitManager.test.ts. It uses the harness from the fix's own test, which records every git process the manager starts. The test copies the issue's setup, 3 tracked files with a line appended to each and nothing staged, then runs a typed-messagerunStackedActioncommit. Before #40282 the commit runsadd -Atwice and expands a throwaway index (update-index --no-split-index). On currentmainit runsadd -Aonce and builds no throwaway index. Both commits contain all 3 files and leave a clean tree. The output lists every git process, 24 before and 20 onmain.I also checked it in the real app with the issue's setup. Nothing is simulated. The project is a no-remote clone of this repository at 511447a (33,228 files). I appended a line to
README.md,package.jsonandAGENTS.md, then committed from the Git actions menu with the typed message "perf commit 1". I counted git processes under therunStackedActionspan with the issue'sunder.cjs. Before #40282 the commit took 1,671 ms and 25 git processes, withcommit.addAllandcommit.unmergedPathstwice each and fourprepareCommitContextsteps. Onmainit took 1,093 ms and 21 git processes, withcommit.addAllonce and noprepareCommitContext. Both commits contain the same 3 files. The status reads around the commit differ from the build in the issue, so neither total is 20. This was one commit each on macOS, so treat the timings as rough.66441268e8)main(63fa4c892e)To reproduce, run
bash prove-issue-40248.shfrom a clean t3code checkout aftervp i.main63fa4c8: prove-issue-40248.out.txtResult
juliusmarminge commentedon Nov 23, 2026
#40282, now on main: Typed-message commits with an unchanged index now skip the throwaway commit context and stage the worktree once, with regression coverage for empty results, selected files and merges resolved to HEAD's tree.
Not done: The issue still requires six before/after Windows runs on the same seed demonstrating at most 15 git processes and approximately 1.5-second click-to-result time; the merged PR explicitly leaves those measurements unverified.
Closing; open a new issue if what is left still matters to you.