-
Notifications
You must be signed in to change notification settings - Fork 41
Description
This was reported in an old issue in the metrics
crate -- metrics-rs/metrics#230 -- but essentially the user was hitting the line where we hypothesized that something was amiss if we managed to wrap around when calling u64::next_power_of_two
.
Thinking on this some more, one potential explanation is that the user had different TSC offsets on different cores, and somehow they were hitting a case where the source measurement happening in adjust_cal_ratio
was actually on a core where the TSC value was smaller than the value taken initially via Counter::now
in calibrate
.
That would seemingly explain how the end - start
calculation could yield a number that would cause next_power_of_two
to overflow, and as long as the absolute delta was smaller than (2^64)-(2^63), we'd always end up with a value that would trigger that overflow.
The bigger question might be: why did this user's set-up somehow manage to trigger this behavior, even at the quoted "maybe once out of 20 times" rate, when quanta
is used in many applications that never seem to experience this?