-
Notifications
You must be signed in to change notification settings - Fork 417
use a monotonic clock for timeouts #253
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
|
||
if defined?(Process::CLOCK_MONOTONIC) | ||
def clock_time | ||
Process.clock_time Process::CLOCK_MONOTONIC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tenderlove Should this method be clock_gettime
?
This is a Ruby feature I wasn't aware of until you created this PR so thank you for pointing it out. This solves a problem we've discussed in another issue. A ton of tests are failing, however. Should the method call be this? http://ruby-doc.org//core-2.2.0/Process.html#method-c-clock_gettime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it should be. That's what I get for not running the tests. >_<
I'll update the patch
We should use a monotonic clock for timeouts so that if the time changes on the system it will not impact the timeout code.
2cf9364
to
c498ed6
Compare
No sweat. Our tests take a long time to run. Even I skip them occasionally! |
use a monotonic clock for timeouts
Also, this code will result in allocations of floating point objects. If we only care about resolution down to the second, we could do:
Which will only give integers (so they should be allocation free) |
Aren't small-enough |
Actually you're totally right. If they are small enough, they won't be allocated. So nevermind! ✨ |
We should use a monotonic clock for timeouts so that if the time changes
on the system it will not impact the timeout code.