-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
use monotonic timer for time delta calculations #10572
Comments
Well, I started looking into this a bit, and unfortunately it's not as easy as I'd hoped. We use time.Time for time delta calculations in all kinds of fun ways, including the return value of Sad to say, I'm not seeing a nice way out of this one. Ideas? |
The easy solution is to wait for go1.9 and the Closing as I don't think there is anything easy to do on our end. |
Once we are on 1.9, it might be a good idea to have a goroutine monitor the system clock periodically and panic if it sees the clock jumping back or forward by more than the allowed clock skew. |
We already have this code in timeutil.Now, though it currently only logs a warning. |
I think you mean |
You're right on both counts.
…On Mon, Mar 6, 2017 at 7:08 PM, RaduBerinde ***@***.***> wrote:
I think you mean hlc stuff not timeutil. It only detects backward jumps
though, and not with any degree of reliability - if I turn the clock back
1s and then I wait 1s before doing anything that requires reading the
clock, it won't get detected (I think).
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#10572 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABdsPIx14l6TUSFhXvZCgwEvYIg5DtKHks5rjKAKgaJpZM4Kt7JX>
.
|
Things like timeouts or
mutex held X for Yms
should not be usingtime.Now
which is dependent on the system clock. Most unix systems have support for a monotonic timer which can be reliably used for time period calculations.Unfortunately there isn't a standard one in Go (golang/go#12914). But that discussion mentions a package which makes use of an internal
runtime.nanotime
fuction which uses a monotonic timer when available: https://github.com/aristanetworks/goarista/tree/master/monotimeNote that a monotonic timer can't be used for txn timestamps or things like that.
The text was updated successfully, but these errors were encountered: