A first build of the request rows runs on any upgrade that changes
internal/usage (the cache key hashes its source) and on a first install.
Each prefetchEach worker holds a whole file's calls while it reads, so
eight of them stacked up in the cold peak.
Measured on mote with a copy of the owner's real accounts and history
(HOME ~/r2278/acct, requests-v1.bin removed before each start), five
cold starts of each build alternated, physical footprint peak at 12s
(vmmap):
eight workers: 248.3 259.1 252.1 257.5 276.1 MB (mean 258.6)
four workers: 243.3 230.2 232.6 245.2 246.7 MB (mean 239.6)
Every four-worker run is below every eight-worker run. The build takes
the same time: the gctrace burst ends at 5.0/5.0/5.6/5.0/6.2s against
5.0/4.8/4.9/5.0/6.4s, and CPU in the first 12s is 6.7-7.6s for both.
The cache written is the same size (71,523,711 bytes) for both.
TestPrefetchEachMakeIsAReadersOwn counts four readers' makes now.
Run at this head (rebased on 8fe720453), on mote: gofmt -l clean,
go test ./internal/usage ok. go test ./internal/gui: red only in
TestCoreScriptBudget (#6116) and TestSettingsSaveKeepsWhatItDoesNotSend
(#6103), both red on main at 8fe720453 and filed; this change touches
no GUI file.
Not run: the full ./... suite.
A cold Requests build (every upgrade) read the call shards eight at a
time, but turned every call into a row on the one loop that takes them:
logRecord, the account resolver, pricing, interning and packing, ~1 s
of serial CPU over a real history, with the readers waiting on the
window behind it.
prefetchSources becomes prefetchEach: each reader has a make of its own
from newMake, and the loop has its own for a source not wanted. Request
rows are made there. Each make has its own Pricer and Swapped memo, so
neither needs a lock; the session resolver is made once (sync.OnceValue)
and only read after. The serial number is still given in the loop, in
source order. The window now holds packed chunks, smaller than the
calls it held.
Measured on a copy of real data (15,656 shards, 3,451 Claude Code
subagent meta files), GUI warm-up step 2 (QueryPage(All)), cold
(requests-v1.bin written for the other binary), alternating runs:
- before (432393217): 3.24 s / 448 MB maxrss, 2.18 s / 433 MB
- after: 1.85 s / 417 MB, 1.84 s / 410 MB
The readers are now mostly in syscalls (shard and meta.json reads).
Run at this head (432393217 + this):
- go test -count=1 -timeout 45m ./internal/usage: ok; with -race: ok
- go test -count=1 -timeout 45m ./internal/gui: one red,
TestRestartHandsTheGatewayOver (18 of 19 requests answered, EOF), the
open #3451; alone -count=5 it passes. Load was ~45.
- TestPrefetchEachMakeIsAReadersOwn: 9 makes (8 readers, the loop's
own) and no race. Broken by hand: one make shared by every reader ->
-race reports DATA RACE, red.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui
./internal/usage ok.