mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-28 16:58:31 +01:00
The metrics table is clustered by resource, so every commit rewrites the newest leaf page of each resource it touches. With a 5-second flush each 30-second agent sample landed in its own commit: about 1.9 WAL pages per sample, 34 times the row data, and about 6.6 GiB/day for 270 resources. Flush the write buffer every 60 seconds instead (buffer ceiling 10,000 rows) and name the raw rollup age so the flush stays well inside it. Readers keep 5-second freshness: a Query* read whose own series has a buffered sample older than 5 seconds flushes the buffer first, exactly as Flush does and bounded by the existing 2-second write wait, and concurrent readers wait for that flush. QueryCommitted skips the flush for the alert metric window and the storage capacity trend, which merge their own fresh in-memory tail; through a flushing read the alert path committed the buffer about ten times a second. Minute batches are up to 20 times larger, so the write queue is also bounded by samples, at the old worst case of 50,000. The full-buffer detach, flush tick, Flush and shutdown drain are otherwise unchanged. With the nightly watch's agent estate on pulse-dev, total Pulse writes fell from about 4.9 to 1.4 GiB/day with identical committed rows, every report accepted, and memory and CPU unchanged. pkg/metrics passes, also under -race, as do the monitoring history, alert window, chart, reporting and Assistant tool tests. TestStoreIdentityMigrationDeduplicatesLegacyRows fails 2 of 20 runs on unchanged main and passed 20 of 20 with this change.