Files
magpie/internal/gui
yetone 53b2773d77 providers: each model priced once, on catalogs worked out once per provider
The Providers page asked PricedFree and ListPrice of every model of
every provider on each ask. Each ran listPrice, which worked out the
provider's catalogs again (Catalogs' split, EndpointCatalog, the
membership filter, kimiCodeMember's split once more), made the names
to look up on the heap, and built userPrice's three keys as strings.
A heap profile of 40 /api/providers asks with real accounts put 4MB
there (2MB catalogs, 1.5MB names).

provider.Pricer works the catalogs out once per provider (priceCats,
kimiCodeMember included), and Prices gives a model its list price and
its free mark from one listPrice. The names go into a stack buffer,
userPrice skips its keys when the user set no prices and otherwise
looks them up from a stack buffer without a copy, and PricedFree's
plan filter copies the list only when a plan's catalog is in it.
ListPrice and PricedFree keep their answers; they now share listPriceIn.

Under the request's holds, two models priced went from 6 allocations
and 10.5us to 0 and ~4us (213us to 4us outside a hold, where
plugin.Cached stats plugins.json for each unpriced model).

TestPricerAllocatesNothingPerModel: 0 allocations for a model, priced,
at $0 or unpriced, under the holds; red (7) when Prices works the
catalogs out per model again. TestPricedFreeIsTheProvidersOwnZero now
also checks Pricer.Prices against ListPrice and PricedFree for every
case, with and without the user's prices.

Run on mote: go test ./internal/provider ./internal/gui
./internal/catalog ok; vet gui and provider for darwin and windows,
provider for linux, ok. Real accounts (sandbox HOME copy), 40 asks
paired twice with the build before: listPrice/PricedFree (~1.5MB a run
there) no longer show in the profile; the totals are within the
+-15MB run-to-run noise (95.7/90.5MB before, 97.0/98.4MB after).
2026-11-10 04:47:19 +08:00
..
…
2026-11-10 03:25:44 +08:00
…