Repository navigation
Description
What is slow
In Settings → Archived threads, every Unarchive click fetches the full archived snapshot (orchestration.getArchivedShellSnapshot) twice in the same millisecond, and every Delete fetches it three times. Each response carries every archived thread's shell (about 1.9 KB per thread), so at 68 archived threads every extra copy is about 115-127 KB on the wire and 40-170 ms of server work. The row is removed only after a snapshot arrives, so the user waits on this: a delete takes a median 789 ms to disappear. Remote clients pay the extra bytes over the relay.
Measured
- Windows Server 2025, 4 vCPU, 16 GB, Defender real-time scanning on, commit 194025e.
- 100 replay threads in two projects (32k-file repositories), 68 of them archived from the sidebar. Headless Chromium on
/settings/archived. - Unarchive, 7 runs (68→61 archived):
getArchivedShellSnapshotsent 2 times per click on every run, both in the same ms about 50 ms afterthread.unarchive. Two responses of the same size per click (for example 49,152 + 49,152 + 26,781 bytes received twice). Row gone median 279 ms (250-400). - Delete (with Confirm), 7 runs (61→54 archived): 3 snapshots per delete on every run: two in the same ms about 65 ms after
thread.delete, then a third 60-100 ms later. 102-114 KB each. Row gone median 789 ms (494-922). - Server trace: each
orchestration.getArchivedShellSnapshotspan took 42-169 ms.
+0 orchestration.getThreadFamily
+7 orchestration.dispatchCommand {"type":"thread.delete",...}
+72 orchestration.getArchivedShellSnapshot {}
+73 orchestration.getArchivedShellSnapshot {}
+135 orchestration.getArchivedShellSnapshot {}
How to measure it again
- Check out the commit in
C:/p/wt, runvp i, thenvp buildinapps/web. - Make a large repository with a remote:
git clone --bare --no-local <a t3code checkout> C:/p/repos/remote.git,git clone C:/p/repos/remote.git C:/p/repos/p0, set user.name and user.email,git checkout -b work; git push -u origin work. - Write
C:/p/home/userdata/settings.json:{"providerInstances":{"devReplay":{"displayName":"Replay (dev)","driver":"acpRegistry","config":{"source":"local","commandPath":"<node -p process.execPath>","commandArgs":["C:/p/wt/apps/server/scripts/dev-replay-agent.ts"]}}}}. - In
apps/server, withT3CODE_DEV_SEED=0:node src/bin.ts serve --base-dir C:/p/home --port 4800 --host 127.0.0.1(over SSH, start it withInvoke-CimMethod Win32_Process Create). Thennode src/bin.ts project add C:/p/repos/p0 --base-dir C:/p/home(repeat if the first attempt fails). - Seed 100 threads: from inside the repository, run
node C:/p/wt/apps/server/src/bin.ts thread start --base-dir C:/p/home --provider devReplay --model command-output C:/p/repos/p0 goin 4 parallel loops (about 30 threads a minute). Archive about 70 from the sidebar (right-click, then Archive). - Pair:
node src/bin.ts pair --ttl 1h --base-dir C:/p/home. ExportPAIRas the printed...pair#token=...URL with its host replaced by127.0.0.1:4800, andPWasnode_modules/.pnpm/playwright@*/node_modules/playwright. node settings.cjs unarchive 7, thennode settings.cjs delete 7.
common.cjs:
const fs = require('fs');
const { chromium } = require(process.env.PW);
const NL = String.fromCharCode(10);
exports.open = async (path) => {
const browser = await chromium.launch();
const page = await (await browser.newContext({ viewport: { width: 1600, height: 1000 } })).newPage();
const sent = [];
page.on('websocket', (ws) => ws.on('framesent', (f) => {
try { for (const line of String(f.payload).split(NL)) { if (!line) continue; const j = JSON.parse(line); if (j._tag === 'Request') sent.push({ t: Date.now(), tag: j.tag, p: JSON.stringify(j.payload).slice(0, 160) }); } } catch {}
}));
await page.goto(process.env.PAIR);
await page.waitForTimeout(4000);
const env = fs.readFileSync('C:/p/home/userdata/environment-id', 'utf8').trim();
await page.goto('http://127.0.0.1:4800' + path.replace('ENVID', env));
return { browser, page, sent };
};
exports.record = (tag, rec) => { fs.mkdirSync('C:/p/perf/out', { recursive: true }); fs.appendFileSync('C:/p/perf/out/' + tag + '.jsonl', JSON.stringify(rec) + NL); };
exports.reqs = (sent, a, b) => { const c = {}; for (const s of sent) if (s.t >= a && s.t <= b) c[s.tag] = (c[s.tag] || 0) + 1; return c; };
exports.seq = (sent, a, b) => sent.filter((s) => s.t >= a && s.t <= b && s.tag !== 'server.reportClientActivity').map((s) => '+' + (s.t - a) + ' ' + s.tag + ' ' + s.p);settings.cjs (all seeded threads share one title, so it waits for the button count to drop):
const { open, record, reqs, seq } = require('./common.cjs');
(async () => {
const action = process.argv[2]; const runs = +(process.argv[3] || 7);
const { browser, page, sent } = await open('/settings/archived');
const recv = [];
page.on('websocket', (ws) => ws.on('framereceived', (f) => { const s = String(f.payload); recv.push({ t: Date.now(), n: s.length }); }));
const label = action === 'unarchive' ? /^Unarchive / : /^Delete /;
await page.getByRole('button', { name: label }).first().waitFor({ timeout: 60000 });
await page.waitForTimeout(6000);
for (let i = 0; i < runs; i++) {
const all = page.getByRole('button', { name: label });
const before = await all.count();
let t0 = Date.now(); await all.first().click();
if (action === 'delete') { const dlg = page.getByRole('alertdialog').or(page.getByRole('dialog')).last(); await dlg.waitFor(); const b = dlg.getByRole('button').last(); t0 = Date.now(); await b.click(); }
await page.waitForFunction(([re, n]) => [...document.querySelectorAll('button[aria-label]')].filter((b) => new RegExp(re).test(b.getAttribute('aria-label'))).length < n, [label.source, before], { timeout: 20000, polling: 10 });
const tGone = Date.now();
await page.waitForTimeout(3500);
const t1 = Date.now();
const big = recv.filter((r) => r.t >= t0 && r.t <= t1 && r.n > 2048).map((r) => '+' + (r.t - t0) + ' ' + r.n);
record(action, { run: i, start: t0 - 200, end: t1 });
console.log(JSON.stringify({ run: i, goneMs: tGone - t0, reqs: reqs(sent, t0, t1), big }));
console.log(seq(sent, t0 - 100, t1).join('\n'));
}
await browser.close();
})();Where the time goes
apps/web/src/components/settings/ArchivedThreadsPanel.tsx,handleThreadAction: afterunarchiveThreadorconfirmAndDeleteThreadsucceeds, it callsrefreshArchivedThreads()(useArchivedThreadSnapshots().refreshinapps/web/src/lib/archivedThreadsState.ts), which runsappAtomRegistry.refreshon the snapshot atom.apps/web/src/hooks/useThreadActions.ts:unarchiveThreadanddeleteThreadalready callrefreshArchivedThreadsForEnvironmenton success, the same atom refreshed in the same tick. Two refreshes in one tick send two requests; they are not merged.packages/client-runtime/src/state/orchestration.ts,archivedShellSnapshot.refreshTrigger: the shell reports deleting an archived thread as a removal (removedAt), which refetches a third time on delete.
Why it is avoidable
The panel's own refresh asks again for what the action it just called (and, for delete, the shell trigger) already asks for. One snapshot per action gives the same final list.
What a fix has to show
The same driver before and after, on Windows:
- Unarchive: 1
getArchivedShellSnapshotrequest and response per click (from 2). - Delete: 1 per delete (from 3). Open PR perf(client): archiving a thread fetches the archived list once, not twice #40443 removes
useThreadActions' refresh after delete, which brings delete to 2 (the panel's refresh plus the shell trigger) but leaves unarchive at 2. This issue covers what is still duplicated after it. - What stays: one full snapshot per action, sized by the archive (about 1.9 KB per archived thread). Making that read smaller is [Bug]: Archived threads take 6 to 18 s to load: getArchivedShellSnapshot reads every archived thread, and one API client can hold all four readers #32805 and A branch switch in a worktree shared by many archived threads makes the client reload the whole archived list once per thread #38321/fix(client-runtime): a branch switch shared by many archived threads reloads the archive once #38336.
- Not regressed: the row disappears without a manual refresh, an unarchived thread reappears in the sidebar, and another client's archive still shows up on this page.
Found by the automated Windows performance sweep on 194025e.
Found by the automated Windows performance sweep on 194025e.
Activity