Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(scripts): a server metrics run catches CPU, memory and first-request regressions #41159

Mergedjuliusmarmingemerged 10 commits intomain fromrefs/pull/41159/headmerged by juliusmarminge View on GitHub

Showing 6 changed files with 24 additions and 1 deletion (loading 4).

x
0 of 6 viewed, 6 left
23 additions and 0 deletionsdocs/internals/performance-regressions.mdModified
View file
@@ -97,6 +97,29 @@
provider with 250 slash commands and 200 skills. The lists load with the first cwd snapshot, and a
machine refresh sends back an empty provider list.
​
+## Server process metrics
+​
+`node scripts/server-metrics.ts run --out <file>` starts a checkout's server against throwaway
+state, a fake Anthropic API and the real `claude` CLI, and records server CPU, wakeups, RSS and
+heap at rest, with quiet Claude threads and with 5 streaming, plus how long a new thread takes to
+reach the API. Only the server process is measured.
+​
+- Compare refs with `ab <checkoutA> <checkoutB>`, not with two files from different times. It
+ alternates the two on one machine, and `compare` flags a metric only when the bootstrap interval
+ of the median difference clears both the threshold and the noise floor. Single runs on a busy
+ machine differ by more than most regressions.
+- Read per-thread cost from `scaling`, a fit over 5 to 20 open threads. It separates what each
+ open thread costs from the fixed cost of the server, which the absolute numbers mix.
+- `--soak <minutes>` reports heap and RSS slopes in MB per hour and the constructors that grew.
+ A rising heap floor is a leak; a high but flat one is not.
+- The quiet and streaming windows save a CPU and an allocation profile, so a regression comes with
+ the functions that cost it.
+​
+Run it on macOS and Windows too, and on Linux with `--no-agent-scope`. Only Linux has agent
+scopes, so other platforms take per-process paths a Linux server with a systemd user manager never
+runs. A one-second `ps -A` poll per Claude session cost 0.1.11 about 18% of a core with 20 open
+threads on macOS and went unnoticed on Linux.
+​
## Event store and startup
​
Sequence cursors must seek an index rather than scan retained history. The application sequence