/api/providers prices every model of every provider on each poll, and
pricedNames ran grokWindow and grokEffort over each id, lowercasing it
twice. Both patterns need "grok-" in the lowercased id, so any other id
now returns before them; what a Grok id is priced as is unchanged.
pricedOnce's memo key is sized once instead of growing by doublings.
Run (on mote unless named):
- go test -count=1 -timeout 45m ./internal/provider ok (103.8s),
./internal/catalog ok; GOOS=linux and windows go vet of both ok;
gofmt clean (here).
- Broken by hand: the guard narrowed to "grokx-" turns
TestGrokEffortListPrice, TestCursorGrokFastPrice and
TestGrokWindowWithoutKListPrice red, so the Grok aliases are covered.
- Here, 200 GET /api/providers on the sandbox with the real config
copy (offline, proxy :9), against v0.1.2548's tree: pricedNames
0.28s -> 0.02s, ListPrice 0.63s -> 0.40s; process CPU 4.62s ->
4.24s, median 20.4ms -> 19.0ms. pricedOnce stayed ~0.20s: its cost
is the key's bytes, not the growth.
Not run: the full ./... suite; GUI tests (the JSON is the same).
The GUI's provider list prices every model of every provider on each
request of /api/providers: ListPrice asks catalog.PricedBy and
MakerPriced by every spelling of the id across every maker's catalog,
and a model none of them lists (most of a relay's) went through all of
them each time. In a CPU profile of the GUI's polls (drift, state,
providers, 40 rounds, a real-account sandbox) ListPrice was 14% of the
process's CPU, PricedBy and makerListPrice most of it.
What PricedBy and MakerPriced find depends on the loaded catalog, the
providers asked and the id, and nothing else, so pricedOnce keeps it by
those for the load's Reset count (gen), as priceIndexOf and AtEndpoint
keep what they build. A Reset (a new catalog synced) starts it again; it
holds at most 32,768 answers and starts again past that. find runs
without the memo's lock, as PricedBy calls itself for a renamed id.
Run on mote (macOS 27, Go 1.26.8) at this tree:
- gofmt clean; go vet ./internal/catalog on darwin, GOOS=windows and
GOOS=linux ok.
- TestPricedOnceALoad 3 of 3 alone, and with -race beside
TestPricedBy*/TestMakerPriced*: ok.
- Broken by hand: the memo never answering, TestPricedOnceALoad red
("looked for 20 times again at one load"); the memo not keyed by gen,
red (the old catalog's 0.15 after a new one's 0.2).
- go test ./internal/catalog ./internal/provider ./internal/usage ok.
./internal/gui: TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
TestMainWindowCorners/macOS_26_SDK (#3949) red, the same two red with
the same output at origin/main ccb75030a on mote.
Real use, this machine, a copy of the real accounts in a sandbox HOME
(proxy blocked, MAGPIE_NO_STATS=1), v0.1.2518's tree (old) against this:
- /api/providers: 1506 models, 938 with a list price; every model's
list and price the same in both. The rest of the reply differs only
in fetched times and one login's lapsed time.
- 40 rounds of drift + state + providers, twice each, alternated:
providers 28.4/27.6ms old, 24.4/24.6ms new; process CPU 2.09/2.03s
old, 1.95/1.94s new.
Not run: the whole suite; Windows and Linux runs (nothing here is by OS).