-
Notifications
You must be signed in to change notification settings - Fork 13.3k
use more precise clocks in precise_time_ns when available #11233
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
Conversation
Recent versions of Linux include CLOCK_MONOTONIC_RAW, which is more accurate than CLOCK_MONOTONIC when something like NTP is running. Also, recent versions of FreeBSD include CLOCK_MONOTONIC_PRECISE, which produces a more accurate result, according to the man page.
Personally, I'd prefer to define a MOST_PRECISE_CLOCK definition outside of the rust_precise_time_ns but the code looks okay regardless. CLOCK_MONOTONIC_RAW has been supported since Linux version 2.6.28 which I think is early enough to support. Do we have a lowest supported version written down somewhere on the wiki? |
Using |
Wouldn't it still be more accurate on the order of seconds, since ntp only checks for the time every few minutes? Or do you mean that the hardware clock tends to be inaccurate enough that the adjusted time is more accurate? I just figured that |
The adjustments by NTP seen by |
Right, that's what I mean - if NTP notices that the clock is wrong, it adjusts the clock incrementally, even if the cause wasn't due to an inaccurate clock timer (my laptop has the tendency to lose a few seconds when I accidentally let the battery die, for instance). In cases like this, the clock skew would be making the length of a second less accurate, rather than more. |
For comparison, the OS X and Windows implementations of Python PEP 418 has some relevant investigation: http://www.python.org/dev/peps/pep-0418/#operating-system-time-functions |
http://lxr.free-electrons.com/source/arch/x86/vdso/vclock_gettime.c#L236 Another point in favour of |
@doy: your FreeBSD |
From the discussion here, it sounds like It also sounds like (from the man page), that These all are certainly different clocks, and I don't think that there's "one right answer" here. We may want to expand the |
[`arc_with_non_send_sync`]: No longer lints macro-generated code Fixes rust-lang#11232 changelog: [`arc_with_non_send_sync`]: No longer lints macro-generated code
Recent versions of Linux include CLOCK_MONOTONIC_RAW, which is more
accurate than CLOCK_MONOTONIC when something like NTP is running. Also,
recent versions of FreeBSD include CLOCK_MONOTONIC_PRECISE, which
produces a more accurate result, according to the man page.