2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-12-22 11:21:24 +00:00

Reduce poll timer sampling from ~100% to ~10%

This should improve performance just a little bit
This commit is contained in:
asonix 2024-12-09 19:14:46 -06:00
parent 04bde6cf20
commit 8a551fa65d

View file

@ -141,6 +141,9 @@ where
let out = this.inner.poll(cx); let out = this.inner.poll(cx);
let elapsed = start.elapsed(); let elapsed = start.elapsed();
// only record 1 in 10 polls
if elapsed.as_micros() % 10 == 0 {
if elapsed > Duration::from_micros(10) { if elapsed > Duration::from_micros(10) {
metrics::counter!(crate::init_metrics::FUTURE_POLL_TIMER_EXCEEDED, "timer" => this.name.to_string()).increment(1); metrics::counter!(crate::init_metrics::FUTURE_POLL_TIMER_EXCEEDED, "timer" => this.name.to_string()).increment(1);
metrics::histogram!(crate::init_metrics::FUTURE_POLL_TIMER_EXCEEDED_SECONDS, "timer" => this.name.to_string()).record(elapsed.as_secs_f64()); metrics::histogram!(crate::init_metrics::FUTURE_POLL_TIMER_EXCEEDED_SECONDS, "timer" => this.name.to_string()).record(elapsed.as_secs_f64());
@ -186,6 +189,7 @@ where
elapsed.as_micros() elapsed.as_micros()
); );
} }
}
out out
} }