Files
magpie/internal/catalog
yetone e6184b368a provider: a provider's models.dev models are read, not copied three times
Provider.available, the base of every Available and Exposed, made three
copies of a provider's catalog models on each call: catalog.Provider
cloned the built list, available appended it into a list of its own to
drop an id two catalogs share, and the list without experiments and
previews was grown from nothing again. On a page open with the owner's
accounts that was 74 MB of 952 MB allocated in 2m32s, the largest flat
allocator of all.

catalog.ProviderShared is the built list itself, for a reader
(catalog.Provider still hands out a copy). available reads it through
catalogsOf, which copies only when two catalogs are joined, and sizes
the released list before filling it. The shared list is never returned:
every way out of available returns Decorate's list, the released copy
or the signed-in account's own. The built list is clipped, so an append
to it reallocates.

Run: go test ./internal/provider ./internal/catalog on mote (ok,
provider 135s). Measured on mote's real-account sandbox (acctp, the
Usage and Providers pages polled for 2m32s, pageheap.sh), w41 = the
parent, w42 = this commit: allocations 993 -> 858 MB, available's
cumulative 144.5 -> 52.3 MB, CPU at the settle mark 3.32 -> 3.18 s;
footprint 130 MB and live heap ~76.7 MB both unchanged. The parent's
full suite at d1e823d5f (same Go tree) was 99 ok, 0 FAIL; this
commit's provider and catalog packages ran again, not the full suite.
2026-11-13 05:15:44 +08:00
..