pub struct BusyMeter { /* private fields */ }Expand description
A shared counter of time spent doing real work.
Every Consumer needs one, and the obvious implementation of it is wrong
in a way that is hard to notice, so it is provided rather than left to each
caller. See BusyMeter::timer.
Implementations§
Source§impl BusyMeter
impl BusyMeter
pub fn new() -> Self
Sourcepub fn timer(&self) -> BatchTimer<'_>
pub fn timer(&self) -> BatchTimer<'_>
Start timing a batch.
The returned timer publishes periodically within the batch, not only at its end. That distinction is the whole reason this type exists.
Publishing once per batch cannot be sampled faster than a batch completes. With a 16384-record batch at a realistic 5 us per record, a batch takes ~80 ms against a 250 ms sampling window — so windows routinely contain no completed batch, read a delta of zero, and report maximum starvation for a consumer running flat out. Measured directly before this was fixed: a deliberately expensive kernel reported 100.0% idle, the exact opposite of the truth, while cheaper kernels reported less.