A provider with no live model list fetched has no live-models file, and
each request asked after it for each of its models (Provider.Exposed ->
ListedAPIs -> catalog.LiveByID -> readLive), each time an os.Stat that
failed: in a CPU profile of a 30-provider, 60-model catalog, os.Stat was
32% of a request, nearly all of it this. A file found unchanged was
already taken as unchanged for heldFor (1s) within a hold; a file found
missing now is too, in the same generation of Forget. Forget (a write
magpie makes), Look(path) (another's write), the hold's end, a second
gone by, or a stat finding the file there drops it. Unheld, every read
still looks.
Numbers, BenchmarkGroupOverhead, 200KB body, stream=false, 100x each,
binaries alternated twice (Apple M4 Pro, loaded by other sessions):
before (cpu-ms/op, allocs) after
30x60 p0/m1 34.69 / 35.14 95126 32.87 / 31.84 89266
30x60 group/g4 44.33 / 43.88 115303 40.77 / 40.77 109071
12x20 p0/m1 15.75 / 16.30 42535 16.22 / 15.09 41645
12x20 group/g4 18.15 / 18.50 54138 18.16 / 17.76 53118
(about 7-8% of a request's CPU on the larger catalog; within noise on
the small one, which has fewer missing files.)
Test: TestHoldMissing: 100 held reads of a missing file make one stat; a
file written meanwhile isn't seen until Forget, and is seen after Forget,
after Look and after the release; unheld, 3 reads make 3 stats. Broken by
hand (the missing check disabled): red, "100 looks at a file not there,
held".
Run: go test ./internal/filememo ./internal/catalog: ok. The full suite
run is in the last commit of this series.