Skip to content
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

IH-628: Add new package for timekeeping #5724

Merged
merged 8 commits into from
Jun 28, 2024

Conversation

psafont
Copy link
Member

@psafont psafont commented Jun 21, 2024

Moves Date to be implemented here, without the deprecated functions, and adds the timer module, which should be enough to satisfy the various efforts needing timers

Draft because Tests are missing

@psafont psafont requested a review from edwintorok June 21, 2024 16:38
clock.opam Outdated Show resolved Hide resolved
@psafont psafont force-pushed the private/paus/timeshares branch 3 times, most recently from a03a775 to 59d46e6 Compare June 24, 2024 13:01
Copy link
Contributor

@Vincent-lau Vincent-lau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, would be good to see how this package is used in xapi

@psafont psafont force-pushed the private/paus/timeshares branch 3 times, most recently from b59aa62 to d2ad74f Compare June 24, 2024 16:12
@psafont psafont marked this pull request as ready for review June 24, 2024 16:13

val span_to_s : Mtime.Span.t -> float
(** [span_to_s span] converts a time span into seconds, represented by a float.
When the span is longer than ~55 years, rounding errors appear. Avoid
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a limit here to 253 nanoseconds using an option? This would make the conversions symmetric in that respect, and we can treat the error at the caller of the RPC function, and not the callee end.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have seen the case float -> span -> float for config parsing.

For RPC, it might be that we encounter the case span -> float -> span, so we need to be wary about those. I'll take care of these conversions when I change them.

@psafont psafont force-pushed the private/paus/timeshares branch 5 times, most recently from e4e548a to b3810bb Compare June 26, 2024 13:27
ocaml/libs/clock/date.ml Show resolved Hide resolved
psafont added 2 commits June 27, 2024 17:17
It currently duplicates the date module from stdext, dropping the deprecated
bindings

Signed-off-by: Pau Ruiz Safont <[email protected]>
Copy link
Contributor

@edwintorok edwintorok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small change in Dune and rounding, and then it passes the quickcheck on the epoll PR.
(I haven't rebased the entire PR yet, but if the tests pass then the rest should work too)

ocaml/libs/xapi-stdext/lib/xapi-stdext-date/dune Outdated Show resolved Hide resolved
ocaml/libs/clock/timer.ml Outdated Show resolved Hide resolved
@psafont psafont force-pushed the private/paus/timeshares branch from 84b0bca to c8fff10 Compare June 27, 2024 16:19
psafont added 2 commits June 27, 2024 17:28
This module can be used to know when a certain amount has passed since the
timer started by polling. Useful for encoding timeouts, schedule actions
periodically and similar.

Signed-off-by: Pau Ruiz Safont <[email protected]>
psafont added 4 commits June 27, 2024 17:28
These could help with the porting of the redo_log code, but Edwin's has working
code that changes the API of the timed calls to use durations instead of
deadlines.

Signed-off-by: Pau Ruiz Safont <[email protected]>
Because the debug module doesn't use best practices, pretty-printers using the
Format module are not ergonomic to use when they are needed for constructing
loglines.

Provide a module for adapters, containing Mtime's spans for the time being.

Signed-off-by: Pau Ruiz Safont <[email protected]>
This allows to define in the code the exact amount of time, including the
measure of time used as base. This is usually minutes.

On top of that it allows for two type of configuration parameters: one that
retains backwards compatibility, using seconds as floats. They can be used to
define relatively short amounts of time (less that 104 days). For longer
amounts of time, seconds can be encoded as integers.

When printing the configuration, both the literal value used to configure the
global and the amount using time units is shown.

Signed-off-by: Pau Ruiz Safont <[email protected]>
@psafont psafont force-pushed the private/paus/timeshares branch from c8fff10 to d75ded9 Compare June 27, 2024 16:28
@psafont psafont merged commit b256bef into xapi-project:master Jun 28, 2024
14 checks passed
@psafont psafont deleted the private/paus/timeshares branch June 28, 2024 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants