Add monotonic clock support#308
Add monotonic clock support#308bikallem wants to merge 3 commits intoocaml-multicore:mainfrom bikallem:clocks2
Conversation
|
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
clockmethod inEio.Stdevn.tis now renamed toreal_clocksince it is in fact an encapsulation of real-time OS clock. The monotonic clock ismono_clock.The real_clock is implemented using
Ptime.tand 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_untileffect inEio_unix.Privatefor both luv and uring backend.make benchnow usesmono_clockto mark start/end time. I believe this is "more" correct than usingreal_clockfor benchmarking purposes.In addition to
Eio.Time.clockbeing polymorhphic, it now also features two functions to make working with time in seconds a bit convenient,to_secondsandadd_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