diff --git a/core/server/dashboard.cpp b/core/server/dashboard.cpp index bb3c2c66..524b5335 100644 --- a/core/server/dashboard.cpp +++ b/core/server/dashboard.cpp @@ -1696,8 +1696,18 @@ function setMetric(key, value, text) { * of diluting it; the engine's prefill rate is itself already windowed. */ const RECENT_S = 15; /* the `recent` window in seconds, for a figure sampled every poll */ const RECENT_PREFILL_S = 5; /* prefill's is shorter, so a several-second prefill shows up in it */ -const extAt = {}, winAt = {}; -let lastActiveC = 0; +const extAt = {}, winAt = {}, extAtS = {}; /* extAtS: the poll at which each extreme was set */ +let lastActiveC = 0, lastStart = null; +/* A new engine process is a different discontinuity from a quiet minute: the previous run's + * requests are gone and its configuration may differ, so nothing from it carries over. Every + * other figure already refuses to pool across a restart -- accWindow drops its rings, histIngest + * resets its base -- and the session extremes are no different, since a best from a run that no + * longer exists is not this lane's best. */ +function newEngineRun() { + resetWindows(); + for (const k in extAt) delete extAt[k]; + for (const k in extAtS) delete extAtS[k]; +} /* Whether the server streams its KV (--kv-resident). Settled at bringup, so it cannot change under * a running page: the cells that name a memory tier read it instead of guessing. */ let kvStreamOn = false; @@ -1706,7 +1716,12 @@ let kvStreamOn = false; function noteSample(key, c, value, capS, win) { if (value == null || !finite(value)) return; const e = extAt[key] || (extAt[key] = {}); - if (!(c in e) || value > e[c]) e[c] = value; + if (!(c in e) || value > e[c]) { + e[c] = value; + /* When the extreme was set, so a figure that outlives its window can say how old it is. */ + const t = extAtS[key] || (extAtS[key] = {}); + t[c] = nowS; + } if (win === false) return; const w = winAt[key] || (winAt[key] = {}); const s = w[c] || (w[c] = []); @@ -1726,7 +1741,16 @@ function triple(key, c, label, fmt, showNow) { const s = (winAt[key] || {})[c]; const tag = typeof c === "number" && c > 1 ? "@c" + c : ""; let out = label + " " + fmt(e[c]); - if (!s || !s.length) return out; + if (!s || !s.length) { + /* The extreme outlives the window by design, so the age is what makes it honest: without it a + * figure from before a gap -- or from before an engine restart, which the page treats as a + * discontinuity everywhere else -- reads as the lane's current best. */ + const t = (extAtS[key] || {})[c]; + /* Only once it is actually stale: an extreme set on this poll is current, and "0 ms ago" + * would be noise. A second is the resolution dur() itself reports below. */ + if (typeof t === "number" && nowS - t >= 1) out += " \u00b7 " + dur(nowS - t) + " ago"; + return out; + } let sum = 0; for (const p of s) sum += p.v; const recent = sum / s.length; @@ -1745,7 +1769,11 @@ function acceptTriple(c, showNow) { if (!e || !(c in e)) return ""; const tag = typeof c === "number" && c > 1 ? "@c" + c : ""; let out = "highest " + pct(e[c], 0); - if (!ring || !ring.length) return out; + if (!ring || !ring.length) { + const t = (extAtS["accept"] || {})[c]; + if (typeof t === "number" && nowS - t >= 1) out += " \u00b7 " + dur(nowS - t) + " ago"; + return out; + } let R = 0, A = 0; for (const d of ring) { R += d.dr; A += d.da; } if (R <= 0) return out; @@ -3849,6 +3877,11 @@ async function poll() { const r = await api("stats"); if (!r.ok) throw new Error(r.status); const s = await r.json(); + /* A new engine process: started_at is its identity, so a change is a discontinuity rather + * than a new measurement. Checked before update() so the new run's samples land in fresh + * windows. */ + if (lastStart !== null && s.started_at !== lastStart) newEngineRun(); + lastStart = s.started_at; const now = performance.now(); update(s, prevAt ? (now - prevAt) / 1000 : 0); prev = s; prevAt = now;