4921bf5a9 (#5892) put provider.UsageNamesKey into usagePriceCacheKey,
the check every GatewaySessions ask, summary and Codex model/effort read
makes before using its kept view. UsageNamesKey reads usageGroupNames,
which asked sharedGroups outside a catalog hold, so each ask built every
provider's entries and the found groups again. In the test sandbox that
was ~130 KB more per ask, enough to take TestGatewaySessionsHandOutTheKeptProjection
over its bar on macOS CI and Windows (547208 / 671560 > 552000). With
real providers it is a whole catalog build on every Sessions poll.
usageGroupNames now holds the catalog (provider.Hold), and so does
usagePriceCacheKey, so provider.All and the group names it reads share
one build. A held catalog is checked against the providers' and
settings' files at the first hold and dropped on any write, as for every
GUI request.
Found by bisect on mote over TotalAlloc per ask: 44732325e 407218,
4921bf5a9 537040.
Run at 9522288b1 plus this change:
- mote (macOS): go vet -tags nogui and go test -count=1 -tags nogui
./internal/provider ./internal/usage: ok. Before the rebase, the same
plus ./internal/sessions ./internal/usageapi ./internal/gui: ok.
An ask allocates 381834 bytes (was 547208); the Codex effort build
271472 against 456152.
- xiaomi-gpu (Windows): both allocation tests pass, 399501 and 371480
(were 699558 and 488640 at origin/main 87dfc0d0b, both red).
The package run of ./internal/usage ./internal/provider is red on
18 tests there; each one that also ran at origin/main 87dfc0d0b is red
the same there (Codex keychain, TestDesktopSessionAccountMetadata,
TestGitOnDisk*, TestResolveKeptAcrossRequests, TestSavedButSignedOut,
TestPricerAllocatesNothingPerModel, TestLANNeighbours), and
TestUsageReadAndReadAgain is #4796 (equal clock readings). Filed the
two with no issue: #6024, #6025.
- gofmt -l: clean.
Broken by hand:
- both holds out (origin/main): 547208 on mote, red.
- only usagePriceCacheKey's hold out: 414295, green; it is the
provider-side hold that fixes the class (UsageAlias and PublicRefs
read usageGroupNames too).
Not tried: a real config with many providers (the saving there is a
catalog build per ask, not measured), and Linux.