The warm-up's last step reads Codex's per-thread effort from the whole
ledger right after the usage page's read, while that page still holds
every row (~300 MB live on the owner's history). It ran at GOGC 100, so
the heap was let grow to about twice that: a heap profile every 2 s of a
cold start showed heapSys going 342 -> 622 MB while live stayed ~300,
in the seconds after QueryPage returned. It now runs under underTightGC
like the usage read.
Footprint (phys_footprint, what Activity Monitor shows), cold start on a
clone of the real history (15,176 files), alternating, two runs each:
4042aa4d1 peak 611 / 575 MB end RSS 659 / 651 MB CPU 4:20.6 / 3:54.9
this peak 521 / 498 MB end RSS 595 / 568 MB CPU 4:11.7 / 4:00.7
Tests: TestWarmUpReadsCodexEffort now also checks the read runs at
GOGC 25; with the step put back to warmCodexEffort() by hand it is red.
go test ./... -timeout 45m on 083b1c8e7: 68 packages ok; rebased onto
b3f595349 (routing CSS/JS only), go test ./internal/gui ok again.
GOOS=linux and GOOS=windows go vet -tags nogui ./... clean; gofmt clean.
The first Sessions page after a start that showed Codex rows read
usage.CodexModelEffort cold, from the whole ledger, while the page
waited. The warm-up now reads it as its last step, after the stats it
already warmed, and only when those stats hold a Codex session; every
later ask is answered from what CodexModelEffort keeps per period.
The steps move into warmSteps() so a test can run them.
TestWarmUpReadsCodexEffort: with Codex keys in the stats the step reads
the effort once, with none it reads nothing. With the step removed: red,
"read 0 times, want 1".
Measured on the same sandbox as the commit before (600k gateway calls,
~4,600 sessions), base 1a3b92688 against this branch, back to back, at a
load average of 350-480 (nine agents running suites):
manage?agent=codex, asked 3.5s after the routes:
base 226s / 190s / 232s (cold) new 247s / 222s / 246s (cold)
It is not faster here: asked at 3.5s, the page arrives before the
warm-up reaches its last step, and both read the ledger at once; the
load makes every one of these numbers mostly CPU wait. The step helps a
first Codex page opened after the warm-up is done, which is the case in
#2776 (a page opened some time after a restart). Not measured at that
point under this load.
Run on origin/main 2ceff7370 with all four #2776 commits' changes
(this one and the three beside it), load average 291-568 (nine agents
running suites), macOS:
- go test -p 4 ./... -timeout 45m, 09:35-10:49: 62 packages ok,
among them agent (2310s), gateway (1707s), provider (764s), usage
(83s). Red:
- internal/sessions: TestWSLOmpProfiles, TestWSLStoppedDistroKept,
TestWSLStoppedSinceNotOpened, TestWSLNoneWithoutHomes, each
"TempDir: mkdir ...: no space left on device" (the disk filled
mid-run). After space was freed, ./internal/sessions alone: ok
(139s).
- internal/gui: TestDockJoinLeadsCommandTab, TestPanelCloseHidesIt,
TestPanelJoinsFullScreenSpaces, TestPluginPageLoadsItsFilesInTheWindow,
TestDockReopenKeepsTheWindowsSpace (each killed at 30s) and
TestMainWindowCorners (86s): the real-window AppKit tests under
load, already filed as #2645 and #1936. Rerun alone at load ~335:
all pass, with TestSetAnswersWhileDevinAndProvidersHang (17s).
- gofmt -l: none. go vet: darwin, GOOS=linux -tags nogui and
GOOS=windows all exit 0.
- No internal/gui/assets file changed, so the GUI Playwright suite was
not run.
The warm-up reads every session file for the Sessions page and Usage › Requests. On a 13.5k-session history it allocates ~830 MB (QueryPage ~570, StatsFor ~260) to keep ~80 MB of indexes, and Go's scavenger returns the freed pages only over the next minutes. warmUp now calls debug.FreeOSMemory once its reads are done: one forced GC and scavenge, once, at start.
RSS of a linux nogui `magpie web` in Docker on a copy of a real config with those sessions mounted read-only, sampled every 15 s from start (with the dsh round change before it): 15 s 472 -> 197 MB, 30 s 475 -> 285, 60 s 417 -> 281, 2 min 337 -> 281, 3.5 min 266 -> 218, 12 min ~250 -> ~204. TestWarmUpReturnsItsGarbage fails without the FreeOSMemory call (10 of 10: 46-334 MB of freed heap still held, or the heap not yet collected) and passes 10 of 10 with it. go test -tags nogui ./internal/gui ./internal/sessions (Docker golang:1.26.8, temp HOME), go vet -tags nogui ./internal/gui for linux, windows and darwin, and gofmt -l pass. Not measured on macOS: a fresh build there hangs at exec behind syspolicyd today.