-
Notifications
You must be signed in to change notification settings - Fork 71
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
Add monotonic clock support #308
Conversation
9f1d565
to
2e33840
Compare
NOTE: This is a non backward compatible change. Specifically, |
You can keep As we're not at Eio 1.0 yet, it's OK to break the API if it's difficult to avoid it, like here. However, if you did want to avoid that it would be possible to add a new module Clock : sig
type 'a t = ...
...
end
module Time : sig
type clock = float Clock.t
...
(* deprecated functions here *)
end |
I have rebased on master now.
Thanks. Yes, I would like to keep the current API set since every other option introduces un-necessary cruft. Could you please approve/merge if there are no further objections. |
1. Makes Time.clock polymorphic 2. Rename clock to real_clock 3. Add mono_clock 4. Change benchmarks to use monotonic clock from realtime clock
Adds Sleep_until effect to Eio_linux.Private and handles the effect in both luv and linux backends.
@talex5 the PR has been rebased to the latest master. |
Based on PR ocaml-multicore#308 by Bikal Lem.
Based on PR ocaml-multicore#308 by Bikal Lem.
Based on PR ocaml-multicore#308 by Bikal Lem.
Based on PR ocaml-multicore#308 by Bikal Lem.
Based on PR ocaml-multicore#308 by Bikal Lem.
Based on PR ocaml-multicore#308 by Bikal Lem.
Now #338 is merged, the remaining parts of this PR (e.g. the use of |
@talex5 It seems this PR has bit rotted quite a bit. Do we still want to use the actual clock to implement timeout functionality, i.e. if mono then we use mono clock, if sys then we use real/sys clock and so forth. If so, I will open another PR rather than continue with this one. Also I believe ocaml-multicore/ocaml-uring#79 in ocaml-uring is required to implement such functionality at least in uring backend. |
Updating the benchmarks to use monotonic times sounds good. Getting eio_linux to use the realtime clock directly would be good too, fixing this comment: eio/lib_eio_linux/eio_linux.ml Lines 1300 to 1304 in 32c26ab
I don't see why that needs ocaml-multicore/ocaml-uring#79. We can just use the new Closing this PR and opening new ones is fine with me. |
My memory is a bit hazy at the moment regarding this. However, the last time I tried this PR, I believe I realized that eventually, timeout value drills down to this bit of code as well. eio/lib_eio_linux/eio_linux.ml Line 581 in 670e656
IIRC the clock defaults to |
You don't need to (and can't) use
|
Closing this since it has bit rotted quite a bit now. |
This PR adds support for monotonic clock to eio. The original
clock
method inEio.Stdevn.t
is now renamed toreal_clock
since it is in fact an encapsulation of real-time OS clock. The monotonic clock ismono_clock
.The real_clock is implemented using
Ptime.t
and mono_clock is implemented usingMtime.t
. There is an open PR to use CLOCK_BOOTTIME as monotonic clock in Mtime (dbuenzli/mtime#44).We now use a common
Sleep_until
effect inEio_unix.Private
for both luv and uring backend.make bench
now usesmono_clock
to mark start/end time. I believe this is "more" correct than usingreal_clock
for benchmarking purposes.In addition to
Eio.Time.clock
being polymorhphic, it now also features two functions to make working with time in seconds a bit convenient,to_seconds
andadd_seconds
.Seconds is chosen as default time unit since it seems to be the unit used by OCaml stdlib. Secondly and subjectively it seems to be a convenient unit to be thinking in terms of time when using time related functions in eio.
Fixes #229
/cc @haesbaert