From 1f47bdb24c16072878fdbaf65ff0c08b7a5e2d53 Mon Sep 17 00:00:00 2001 From: nandi Date: Fri, 31 Jul 2026 14:19:11 -0700 Subject: [PATCH] Keep abnormal process lists for the full session Remove 45s expiry; only drop the oldest when over the cap. --- src/app.rs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/app.rs b/src/app.rs index 3b1374d..07ce4c4 100644 --- a/src/app.rs +++ b/src/app.rs @@ -15,10 +15,8 @@ const SAMPLE_EVERY: Duration = Duration::from_millis(500); const ABNORMAL_FRAC: f64 = 0.80; /// Ignore tiny rates so idle noise never latches an anomaly. const ABNORMAL_MIN_BPS: f64 = 2.0 * 1024.0 * 1024.0; // 2 MiB/s -/// How long to keep each anomaly entry under the gauge. -const ANOMALY_HOLD: Duration = Duration::from_secs(45); -/// Cap list length so the gauge card stays usable. -const ANOMALY_MAX: usize = 12; +/// Cap list length so the gauge card stays usable (never auto-expired). +const ANOMALY_MAX: usize = 32; /// One process that drove an abnormal disk gauge reading. #[derive(Debug, Clone)] @@ -120,9 +118,6 @@ impl UsageApp { self.disk_write_scale.observe(d.write_bps); self.net_rx_scale.observe(n.read_bps); self.net_tx_scale.observe(n.write_bps); - - expire_anomalies(&mut self.disk_read_anomalies); - expire_anomalies(&mut self.disk_write_anomalies); } } } @@ -135,6 +130,7 @@ fn is_abnormal(rate: f64, prev_scale: f64) -> bool { } /// Append a hit; skip duplicate of the same process within a short window. +/// Entries are never timed out — only capped by [`ANOMALY_MAX`]. fn push_anomaly(list: &mut Vec, hit: AnomalyHit) { // Don't spam the same name on consecutive samples — refresh stamp/rate instead. if let Some(last) = list.last_mut() { @@ -151,10 +147,6 @@ fn push_anomaly(list: &mut Vec, hit: AnomalyHit) { } } -fn expire_anomalies(list: &mut Vec) { - list.retain(|hit| hit.at.elapsed() <= ANOMALY_HOLD); -} - impl eframe::App for UsageApp { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { self.tick(); -- 2.51.2