From 7ddf13eb62cbc70b5e57c42261059c23ec5a4699 Mon Sep 17 00:00:00 2001 From: Damocles Date: Wed, 15 Apr 2026 23:42:47 +0200 Subject: [PATCH] perf: reduce nova-stats sysfs read frequency core frequencies now read every 2nd tick instead of every tick (halves per-core sysfs I/O). temperature reads moved to every 4th tick. cpu usage still sampled every tick via /proc/stat. --- stats-daemon/src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/stats-daemon/src/main.rs b/stats-daemon/src/main.rs index b206397..838d32f 100644 --- a/stats-daemon/src/main.rs +++ b/stats-daemon/src/main.rs @@ -201,18 +201,21 @@ fn main() { let stdout = io::stdout(); let mut out = io::BufWriter::new(stdout.lock()); let mut prev: Vec = vec![]; + let mut freqs: Vec = vec![]; let mut tick = 0u64; loop { let t0 = Instant::now(); let curr = read_stat(); - let freqs = read_core_freqs(); + if tick.is_multiple_of(2) { + freqs = read_core_freqs(); + emit_mem(&mut out); + } emit_cpu(&mut out, &prev, &curr, &freqs); prev = curr; - if tick.is_multiple_of(2) { - emit_mem(&mut out); + if tick.is_multiple_of(4) { emit_temp(&mut out); }