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.
This commit is contained in:
Damocles 2026-04-15 23:42:47 +02:00
parent b5e0f47b80
commit 7ddf13eb62

View file

@ -201,18 +201,21 @@ fn main() {
let stdout = io::stdout();
let mut out = io::BufWriter::new(stdout.lock());
let mut prev: Vec<Sample> = vec![];
let mut freqs: Vec<f64> = 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);
}