Files
magpie/internal/sessions
yetone 28ac12bc90 sessions: a pass's prices build the providers once, not once a model
A model's price looks its provider up among every provider
(BasePriceIn → byIDOrWas → All), and with nothing held each look built
every provider again from their files and accounts. keptStill checks
every kept price on each 10 s refresh of the Sessions page, so this was
the largest allocator left there: provider.All 59 MB cumulative, 40.5 MB
of it from sessions.priceOf, in 4 minutes. pricer now holds the
providers for a price it hasn't seen, and what a hold built stays for
heldFor (1 s) after it, so the rest of the pass reuses it.

Run:
- TestPricerBuildsTheProvidersOnce (new) counts provider.AllBuilt
  across six models priced with the real priceOf. Fixed: pass. Broken
  by hand (Hold removed, in a copy): "built every provider 6 times".
- mote: go test ./internal/sessions ./internal/provider
  ./internal/usage ./internal/gui ok; GOOS=windows go vet and GOOS=linux
  go vet -tags nogui ./internal/sessions clean; gofmt clean.
- Real accounts (mote, sandbox HOME copy, ad4.sh: /api/sessions/stats
  for days 0, 7 and 30 every 10 s with X-Magpie-Had, heap at 120 s and
  360 s): total allocated in the 4 minutes 294.3 MB (t68) → 210.1 MB
  (t69); provider.All cum 59.3 → 18.3 MB, allProviders 50.6 → 11.7 MB,
  sessions.priceOf 41.1 → 14.2 MB.

Not tried: Windows and Linux runs of the package (vet only).
2026-11-11 10:03:28 +08:00
..
2026-10-02 08:20:33 +08:00