mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-12 23:31:30 +00:00
f18f15bf7b
The retention and max-points trims re-sliced the series front (metrics[i:]), which keeps the entire backing array reachable while hiding the trimmed prefix from cap(). After the dense mock trends seed (~2,800 points/series) aged out of its 6h window, every series held a few hundred live points while pinning its seed-sized array - roughly 700MB across the demo estate's ~8,000 series. HeapSys drifted over the droplet's memory.high, kernel reclaim throttling starved the accept loop, and demo.pulserelay.pro served 502s (2026-08-25 outage; verified live via pprof: appendMetric-attributed live heap grew +117MB in six minutes after restart while goroutines stayed at 80). Trims now compact in place so cap() reflects the true array size, and releaseTrimmedCapacity copies the window into a right-sized array when it occupies under a quarter of the backing array. A healthy sliding window sits between 1x and 2x capacity and never pays the copy. Regression tests pin both paths: a live append after an aged-out seed backfill, and Cleanup on a mostly-expired series, including an aliasing assertion that catches the cap()-blind front re-slice.