mirror of
https://github.com/monoscope-tech/monoscope.git
synced 2026-11-16 10:18:01 +00:00
perf(infra): read the container pivot from a freshness slice, not the whole window
Over a 24-hour window the containers query did not complete at all — it hit the statement timeout, so `containersInWindowCached` never got a value to store, the 300s TTL never applied, and every load paid the full timeout and rendered nothing. Measured on prod TF against the demo project: 1.77s at 1h, 42.33s at 6h, timeout at 24h. The window was the wrong input. The values shown are by definition the newest datapoint per series, and a series that still exists reports every 15-60s, so its newest datapoint is always within the last few minutes. Scanning further back can only turn up older points that `rn = 1` then discards — while paying to sort every one of them, with ~15 variant_get lookups per row along the way. So the pivot now reads `[max(fromTime, toTime - 15m), toTime]`. Anchored on the window's end rather than on `now`, so a historical from/to range reports the state at the end of the range it selected, and a window shorter than the slice still only reads itself. Result: 0.70s flat at every window — 63x at 6h, and 24h goes from not completing to sub-second. That drops a container which stopped reporting hours ago off a wide window, instead of showing it with hours-old numbers sorted among the live ones by CPU. That is the intended reading of the table, and keeping the old semantics is not affordable: a presence-only query over the window costs 8.77s at 6h and 25.12s at 24h, because the scan is the expense, not the pivot. The result summary now says "reporting in the last 15m" rather than implying the picker's window. Also fixes the two usage charts above the table, which rendered as empty panels. They sized themselves purely by `aspect-ratio: 4/1`, so side by side on a 1600px viewport each canvas got 56px — no plot area for a multi-series line chart with a legend, even though both /chart_data requests returned full datasets. A height floor takes the canvas to 140px; the ratio still governs growth on wide screens. plans/infra-sessions-rum-performance.md has the measurements for all three pages, including why the sessions query is deliberately left alone (every rewrite that stays correct on both backends is only ~1.3x) and why the real fix for RUM's 31x read amplification is the ingest-time category column, not SQL shape. It also records the one UI bug found and not fixed: the containers table is clipped rather than scrollable, and the obvious fix breaks sticky headers app-wide.
This commit is contained in:
parent
3d3076037f
commit
c2ffd32e85
8 changed files with 365 additions and 8 deletions
Loading…
Add table
Add a link
Reference in a new issue