Draft
Conversation
7fb9d63 to
343262c
Compare
From the docs: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/clock?view=msvc-170 > Given enough time, the value returned by `clock` can exceed the > maximum positive value of `clock_t`. When the process has run > longer, the value returned by `clock` is always `(clock_t)(-1)`, as > specified by the ISO C99 standard (7.23.2.1) and ISO C11 > standard (7.27.2.1). Microsoft implements `clock_t` as a `long`, a > signed 32-bit integer, and the `CLOCKS_PER_SEC` macro is defined as > 1000. This macro gives a maximum `clock` function return value of > 2147483.647 seconds, or about 24.8 days. Don't rely on the value > returned by `clock` in processes that have run for longer than this > amount of time.
Sys.times now returns -1 if POSIX clock or times fail on overflow. Unix.times now raises on Unix (it would raise only on Windows). times: https://pubs.opengroup.org/onlinepubs/9799919799/functions/times.html clock: https://pubs.opengroup.org/onlinepubs/9799919799/functions/clock.html
343262c to
264b728
Compare
caml_win32_clock can only run for 24.8 days before overflowing. If we use a uint64_t accounting for 100-nsec intervals, and convert to double (where the maximum integer value is 2**53), the function will report accurate running times for over 28 years.
264b728 to
5d3a425
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
caml_win32_clockoverflowing if wall-clock exceeds 24.8 daysFrom the docs:
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/clock?view=msvc-170
Make
Sys.timereturn -1 on error instead of undefined value