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:
parent
b5e0f47b80
commit
7ddf13eb62
1 changed files with 6 additions and 3 deletions
|
|
@ -201,18 +201,21 @@ fn main() {
|
||||||
let stdout = io::stdout();
|
let stdout = io::stdout();
|
||||||
let mut out = io::BufWriter::new(stdout.lock());
|
let mut out = io::BufWriter::new(stdout.lock());
|
||||||
let mut prev: Vec<Sample> = vec![];
|
let mut prev: Vec<Sample> = vec![];
|
||||||
|
let mut freqs: Vec<f64> = vec![];
|
||||||
let mut tick = 0u64;
|
let mut tick = 0u64;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let t0 = Instant::now();
|
let t0 = Instant::now();
|
||||||
|
|
||||||
let curr = read_stat();
|
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);
|
emit_cpu(&mut out, &prev, &curr, &freqs);
|
||||||
prev = curr;
|
prev = curr;
|
||||||
|
|
||||||
if tick.is_multiple_of(2) {
|
if tick.is_multiple_of(4) {
|
||||||
emit_mem(&mut out);
|
|
||||||
emit_temp(&mut out);
|
emit_temp(&mut out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue