TestListingsOfDifferentSizesMadeOnce went red on macOS CI (run
42998160416, at f10c546db) and in #5990's full run: ten polls of
unchanged folders allocated 71-94 KB against a 64 KiB bound. The 64 KiB
read buffer came from a sync.Pool, which a collection empties, a Get on
another P misses, and -race drops one Put in four of; each such miss
made a new buffer inside the window. In the app, that is a new 64 KiB
buffer on the next poll after each collection.
The buffers are now kept on a small free list under a mutex, up to
four, the way listings already are (stats.go says why those aren't in
a pool). The test runs two collections in its window.
Run on mote at origin/main de13afbf6 plus this change:
- go test -count=20 -run TestListingsOfDifferentSizesMadeOnce ./internal/dirent: ok
- go test -race -count=5 ./internal/dirent: ok (#5990: every -race run failed before)
Broken by hand: the old stats_darwin.go with the new test, -count=5:
5 of 5 red, 73856 to 93624 bytes.
Not tried: Linux and Windows, where the file isn't built and the test skips.