mesh-meter: a span shorter than its counter's minimum window is an estimate #630
Loading…
Reference in a new issue
No description provided.
Delete branch "mesh-meter/min-window"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Every energy counter declares the smallest window over which its readings aren't noise, its
min_window_ns: about 10 ms for RAPL and IOReport, 100 ms for NVML, and 2 s for a Mac's SMC power integral (#622). Over a shorter span, a counter's delta is whatever its updates and rounding happened to give, often zero or a whole update period.Mesh didn't check this and graded such a span at the counter's grade. So a request lasting a few milliseconds could be sealed
HwShuntat 0 µJ, orModelBasedat a power reading stretched over the span.What changes
mesh/SPEC.md§3.3: a span shorter than the minimum window of the counter that would grade it MUST NOT be gradedHwShuntorModelBasedfrom that counter. It counts as an estimate of the request, and SHOULD be billed by an estimator that resolves the span's own length, so a short request is never billed zero.HwMeter:Meter::open_span), whichSessionalready prefers, so every span is timed.HwMeter::min_window) is billed this crate'sEstimatorMeterover the span's own length. It's gradedEstimatorwith nomeasured_uj, the same way a span across a failed read already is.min_windowis zero where the bridge already bills by its estimator.ProcessMeter:ProcessSpanMeterfalls back to the host meter, a span shorter than the host meter's minimum window is billed the same way.jouleclaw-energy: addsProcessSpanMeter::fallback_min_window()(additive), so a caller can apply the rule.Each span is timed from just after its opening read to just before its closing one. That's slightly shorter than the counter's own window, so a span right at the minimum counts as short rather than long.
A caller that subtracts
Meter::snapshots itself gets no such check.Session, whichmesh-coreserves through, does.Verified
Estimatorat the estimator's figure for 20 ms. A 60 ms span keeps the counter's figure and grade, for bothHwShuntandModelBased.mesh-meter(default andhw-meter-rapl),mesh-core(hw-meter-rapl) andmesh-conformancepass. Clippy is clean.mesh-meterandmesh-corepass withhw-meter-apple, including a real in-process serve sealedHwShunt. Clippy is clean formesh-meterandjouleclaw-energy.Follow-up
Once #622 lands,
hw-meter-applecan also enablejouleclaw-energy/smc. The SMC's 2 s floor is now handled, so short serves on a Mac would be estimated rather than sealedModelBased.🤖 Generated with Claude Code