v0.32.6_fix2

This commit is contained in:
Mateusz Gruszczyński committed 2026-10-14 11:51:37 +02:00
1 parent e1ac899ec0
commit fc8711d4d8
39 files changed
+695 -232

No files matched your search

+15 -12
View File
@@ -1,7 +1,7 @@
"use strict";
(() => {
let loading = false, offset = 0, generation = 0;
let liveChartScope = "", liveChartPrevious = null, liveChartPreviousAt = null;
let liveChartScope = "", liveChartPrevious = null, liveChartPreviousAt = null, liveChartGeneration = null;
const liveChartSamples = { hits: [], misses: [], bypasses: [] };
const LIVE_CHART_LIMITS = new Set([60, 120, 300, 600]);
const LIVE_CHART_STORAGE_KEY = "rustproxy.cache.liveChartSamples";
@@ -68,7 +68,7 @@
};
const reason = value => { const key = `cacheReason_${value}`, text = t(key); return text === key ? value : text; };
function resetLiveChart(selected = scope()) {
liveChartScope = selected; liveChartPrevious = null; liveChartPreviousAt = null;
liveChartScope = selected; liveChartPrevious = null; liveChartPreviousAt = null; liveChartGeneration = null;
for (const values of Object.values(liveChartSamples)) values.length = 0;
for (const id of ["cache-live-hit-line", "cache-live-miss-line", "cache-live-bypass-line"]) $(id)?.setAttribute("points", "0,170 900,170");
for (const id of ["cache-live-hit-rate", "cache-live-miss-rate", "cache-live-bypass-rate"]) if ($(id)) $(id).textContent = "0.0/s";
@@ -100,18 +100,21 @@
hits: Math.max(0, Number(counters.hits) || 0),
misses: Math.max(0, Number(counters.misses) || 0),
bypasses: Math.max(0, Number(counters.bypasses) || 0)
}, rates = { hits: 0, misses: 0, bypasses: 0 };
if (liveChartPrevious && liveChartPreviousAt != null) {
const elapsed = Math.max(.001, (now - liveChartPreviousAt) / 1000);
for (const key of Object.keys(rates)) if (current[key] >= liveChartPrevious[key]) rates[key] = (current[key] - liveChartPrevious[key]) / elapsed;
};
const keys = Object.keys(current);
const previous = liveChartPrevious && liveChartPreviousAt != null
? { values: keys.map(key => liveChartPrevious[key]), at: liveChartPreviousAt, generation: liveChartGeneration } : null;
const sample = rustProxyRateSampling.difference(previous, keys.map(key => current[key]), now, rustProxyRateSampling.cadence("cache_seconds"));
liveChartPrevious = current; liveChartPreviousAt = now; liveChartGeneration = sample.next.generation;
if (sample.deltas) {
keys.forEach((key, i) => { liveChartSamples[key].push(sample.deltas[i] / sample.seconds); liveChartSamples[key] = liveChartSamples[key].slice(-liveChartLimit); });
}
liveChartPrevious = current; liveChartPreviousAt = now;
for (const key of Object.keys(rates)) { liveChartSamples[key].push(rates[key]); liveChartSamples[key] = liveChartSamples[key].slice(-liveChartLimit); }
redrawLiveChart();
$("cache-live-hit-rate").textContent = `${rates.hits.toFixed(1)}/s`;
$("cache-live-miss-rate").textContent = `${rates.misses.toFixed(1)}/s`;
$("cache-live-bypass-rate").textContent = `${rates.bypasses.toFixed(1)}/s`;
$("cache-live-chart-value").textContent = `Σ ${(rates.hits + rates.misses + rates.bypasses).toFixed(1)}/s`;
const rate = key => sample.deltas ? `${(sample.deltas[keys.indexOf(key)] / sample.seconds).toFixed(1)}/s` : "-";
$("cache-live-hit-rate").textContent = rate("hits");
$("cache-live-miss-rate").textContent = rate("misses");
$("cache-live-bypass-rate").textContent = rate("bypasses");
$("cache-live-chart-value").textContent = sample.deltas ? `Σ ${(sample.deltas.reduce((a, b) => a + b, 0) / sample.seconds).toFixed(1)}/s` : "-";
}
function configure() {
const selected = scope(); const items = [el("option", t("logAllVhosts"))]; items[0].value = "*";