-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to CLOCK_BOOTTIME and friends to improve accuracy. #58
Comments
Thinking about this more... The issue is specific to when the system is in suspend, which relates to being in a "sleep state", or in ACPI parlance: S1-S5. The aforementioned snippet from the Intel Developers Manual states that the TSC runs at a constant rate in P/C/T-states, but those are mutually exclusive with sleep states. Thus, if Given the performance goals of
The first just makes sense: if we can, we might as well make the monotonic reference clock as close to wall time accurate as possible. The second, well, also just makes sense: There's likely a future change we could make to allow only using the monotonic reference clock, for when users want |
Thinking more about this still, I don't think switching to Consider our thoughts from the last comment: while The above thought about documenting that |
Per the discussion happening on rust-lang/rust#88714, there's a meaningful difference between
CLOCK_BOOTTIME
andCLOCK_MONOTONIC
when it comes to time across system suspends on Linux. According to the issue, the problem they're trying to solve is thatCLOCK_MONOTONIC
stops ticking during suspend, whileCLOCK_BOOTTIME
does not. This raises two problems forquanta
:Monotonic mode
When invariant TSC support is not detected, we fall back to the "monotonic" mode where we query the time directly. This is all fine and good, but we're also querying with
CLOCK_MONOTONIC
, and similar variants on other platforms. This leaves us open to the exact same problem described in the above issue.Counter (TSC) mode
While I have not fully traced whether or not this matters, there's a potential reality where
CLOCK_MONOTONIC
stops ticking during lower CPU power states, such that as we're going through the calibration loop, our reference drifts with every loop we perform. While invariant TSC should be guaranteed to tick at a constant rate -- recent Intel manuals specifically use the language ofThe invariant TSC will run at a constant rate in all ACPI P-, C-. and T-states.
-- this is moot if our initial reference/source calibration is off, as we need that in order to go from TSC cycles to real time units.At any rate, switching shouldn't do anything but make things more accurate, but to reference the issue again, there are also some concerns about when the support for it was introduced, and on which platforms it matters. With that in mind, we likely need to wait for that PR to shake out to make sure we have a good example of where we'll need to make our changes.
The text was updated successfully, but these errors were encountered: