XcodeFish (#2502): with several agents at once the gateway sat at
100-350% CPU. Counting provider.AllBuilt around one streamed chat
request gave 3 full catalogue builds per request, and each build re-read
and re-parsed plugin-auth.json and settings.json (AccountDiscoveryOff
called Load() on every provider list).
- holdCatalog wraps the gateway's handler in provider.Hold() and
filememo.Hold(), so one request builds the providers once and stats
each file at most once a second. Hold already drops the cache on
provider.Changed and on magpie's own writes; another program's write
is seen within the second.
- plugin-auth.json is read through filememo (mtime, size, and the raw
bytes while the file is under 2s old), so it is parsed once per
version. A file that doesn't parse falls back to the last good .bak
through lastgood, as settings does. Auths still hands each caller its
own decoded map. The host looks at the file again before it reports a
sign-in it just saved.
- AccountDiscoveryOff reads the setting through filememo with the same
parse settings.Load uses (now settings.parse), under fileMu.
What was run:
- TestRequestBuildsProvidersOnce: two streamed requests, one build each
(3 each before). Red with holdCatalog taken out.
- TestAuthParsedOncePerVersion: 100 rounds of Auths, SignedIn and the
listing proxies parse plugin-auth.json zero more times; a caller's
edit doesn't leak; a same-size rewrite is read; a zeroed file reads
the .bak and stays signed in. Red with authRaw reading past filememo.
- TestAccountDiscoveryOffParsedOnce: 100 calls, no parse; a Save is
read. Red with AccountDiscoveryOff back on Load().
- gofmt -l clean; go vet -tags nogui on darwin, linux and windows ok.
- Full suite, set -o pipefail; go test -p 4 -timeout 45m ./... at this
pair rebased on 63be47717, machine load average 170-330 from other
work: 63 packages ok; internal/agent and internal/gateway ran out of
45m (#2544, #2191, #2108); internal/gui TestMainWindowCorners killed
at its 40s deadline (#1936). Run alone afterwards, gateway and agent
ran out of 45m again, and gateway's
TestQuietCodexStreamKeptAliveThroughReplyWriters/a_middleware got its
reply unchanged once, the middleware failing open on its time limit
(filed #2565; 6/6 alone on 63be47717 and here).
- The same two packages on 63be47717 alone, side by side with this
head under the same load: both ran out of 45m there too, in other
tests, so the timeouts are not this change.
Not tried: a benchmark against a real many-agent load, or the
reporter's machine. The count of builds per request is the measure.