Repository navigation
Description
What is slow
When the server checks Claude, at start and on every Settings → Providers → Refresh provider status, it first runs claude --version, waits for it to exit, and only then starts the capabilities probe (claude.exe --output-format stream-json …). The probe does not use the version. On Windows the wait adds ~250 ms (180–360 ms) before Claude's status can update, and Claude is the slowest source in a refresh.
Measured
- Windows Server 2025, 4 vCPU, Defender on. Commit
b568fcbaa6, server from source, production web build in headless Chromium. Claude Code 2.x and Codex installed through npm. 6 projects / 18 threads seeded. - Refresh, 6 clicks (median 2.0 s, 1.63–2.48 s, until no
button[aria-busy=true]):
| click | claude --version ran |
capabilities probe started after the version check started | …after it exited |
|---|---|---|---|
| 1 | 225 ms | 265 ms | 40 ms |
| 2 | 286 ms | 300 ms | 14 ms |
| 3 | 306 ms | 324 ms | 18 ms |
| 4 | 207 ms | 231 ms | 24 ms |
| 5 | 180 ms | 188 ms | 8 ms |
| 6 | 356 ms | 361 ms | 5 ms |
Median: the probe starts 282 ms after the version check starts. In a traced click, refreshAll took 1464 ms and the Claude source (refreshOneSource) 1459 ms, against 603–678 ms for Codex. Claude decides when the refresh ends.
- 5 warm server starts:
claude --version155–503 ms (median 240 ms), always before the probe. - One
claude --versionon Windows is 3 processes (cmd.exefor the npm shim,conhost.exe,claude.exe).
How to measure it again
Setup (Windows, fresh machine)
- Check out the commit, run
vp i, thencd apps/web && vp build. Install the provider CLIs:npm i -g @openai/codex @anthropic-ai/claude-code. Putnpm prefix -gon PATH for the server. - Seed 6 projects of ~32k files each:
git clone --local <a t3code checkout> p<i>for i = 0..5. For p0–p2, setorigintohttps://github.com/pingdotgg/t3code.git,git fetch origin mainandgit branch -u origin/main main. For p3–p5, rungit remote remove origin. In every repo, check outfeature-<i>and commit one file. - From
apps/server, start a seeding server:T3CODE_DEV_SEED=0 node src/bin.ts serve --base-dir H --port 4800 --host 127.0.0.1 --dev-url http://localhost:5733. For each repo, runnode src/bin.ts project add <repo> --base-dir Hand then 3×node src/bin.ts thread start --base-dir H --provider devReplay --model todo-list --wait --json <projectId> "task". Stop the server. - Start the measured server without
--dev-url, with Defender real-time scanning on and no exclusion:T3CODE_DEV_SEED=0 SPAWNLOG=spawn.ndjson node --require ./spawnlog.cjs src/bin.ts serve --base-dir H --port 4800 --host 127.0.0.1. Discard the first start after a Defender change, because it is a cold scan.
// spawnlog.cjs: logs every child process the server starts (pid, args, start epoch, duration, exit code)
const cp = require('child_process'); const fs = require('fs'); const out = process.env.SPAWNLOG || 'spawn.ndjson'; const main = require('worker_threads').isMainThread;
const log = (o) => { try { fs.appendFileSync(out, JSON.stringify(o) + '\n'); } catch {} };
for (const name of ['spawn', 'execFile', 'exec', 'fork']) { const orig = cp[name]; cp[name] = function (...a) { const t0 = Date.now(); const c = orig.apply(this, a);
c.once && c.once('exit', (code) => log({ k: name, main, pid: c.pid, cmd: String(a[0]), args: Array.isArray(a[1]) ? a[1].map(String) : [], at: t0, ms: Date.now() - t0, code })); return c; }; }
require('module').syncBuiltinESMExports();Pair a browser with node src/bin.ts pair --ttl 1h --base-dir H (rewrite the host to 127.0.0.1:4800). Run the driver, then match the spawn log.
// refresh.cjs <playwrightDir> <pairUrl> <n> <out.json>: clicks Refresh provider status n times
const [pw, pairUrl, n, out] = process.argv.slice(2); const { chromium } = require(pw); const fs = require("node:fs");
(async () => { const b = await chromium.launch(); const p = await (await b.newContext()).newPage(); const res = [];
await p.goto(pairUrl); await p.waitForTimeout(15000); const base = new URL(pairUrl).origin;
for (let i = 0; i < +n; i++) { await p.goto(base + "/settings/providers"); await p.waitForTimeout(4000);
const at = Date.now(); await p.getByRole("button", { name: /Refresh provider status/ }).first().click(); await p.waitForTimeout(200);
await p.waitForFunction(() => !document.querySelector("button[aria-busy=true]"), null, { timeout: 60000 });
res.push({ i, at, ms: Date.now() - at }); await p.waitForTimeout(3000); }
fs.writeFileSync(out, JSON.stringify(res)); console.log(res); await b.close(); })();// claudeserial.cjs <spawn.ndjson>: per claude --version, when the capabilities probe started
const L=require("fs").readFileSync(process.argv[2],"utf8").split("\n").flatMap(l=>{try{return[JSON.parse(l)]}catch{return[]}}).sort((a,b)=>a.at-b.at);
const cv=L.filter(o=>/claude(\.CMD)?/i.test(o.cmd)&&/--version/.test(o.cmd+o.args.join(" "))),cx=L.filter(o=>/claude\.exe$/i.test(o.cmd));
for(const v of cv){const p=cx.find(o=>o.at>=v.at&&o.at<v.at+5000);console.log(new Date(v.at).toISOString(),"version",v.ms,"ms; probe +"+(p?p.at-v.at:"?")+" ms after version start, +"+(p?p.at-v.at-v.ms:"?")+" after its exit")}Where the time goes
apps/server/src/provider/ClaudeProvider.ts, checkClaudeProviderStatus. It runs yield* runClaudeCommand(claudeSettings, ["--version"], …) and handles failure, timeout and non-zero exit. Only after that does it run yield* resolveCapabilities(claudeSettings) (probeClaudeCapabilities). The capabilities call takes only the settings. The version feeds the model list (resolveClaudeModelsForVersion), the upgrade message and the error states, and it combines with the capabilities only after both finish.
Why it is avoidable
The two CLI launches are independent, but they run one after another, so the status waits for both durations instead of the longer one.
What a fix has to show
The same 6 refresh clicks and 5 warm starts, before and after:
- The capabilities probe starts within ~50 ms of the version check starting, instead of 188–361 ms (median 282 ms) after it.
- The Claude source span (
refreshOneSourcefor Claude, underws.rpc.server.refreshProviders) is shorter by at least 150 ms at the median. The version run itself (median ~250 ms) does not shrink, and running both at once on 4 vCPUs costs some of the gain. - What stays: both launches, and today's results for every outcome: a missing CLI, a version failure or timeout (the probe's result is discarded and the same error shows), a non-zero version exit, unauthenticated, and versions that need an update.
Found by the automated Windows performance sweep on b568fcb.
Found by the automated Windows performance sweep on b568fcb.
Activity