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

Use clock_gettime instead of gettimeofday for monotonic time on macOS #18380

Closed

Conversation

palpant-dbx
Copy link

As described in #12680, the implementation of GetMillisecondsMonotonic is not actually monotonic on macOS, because gettimeofday can go backwards as a result of NTP time syncs. When this happens, computing duration overflows and fails execution with a message like:

ERROR: While parsing option --startup_time=18446744073709551598: '18446744073709551598' is not a long

This PR changes the implementation to use clock_gettime, which is available since macOS 10.12, with the CLOCK_UPTIME_RAW option. CLOCK_UPTIME_RAW is defined to mean:

clock that increments monotonically, in the same manner as CLOCK_MONOTONIC_RAW, but that does not increment while the system is asleep

This seems appropriate for GetMillisecondsMonotonic which is used exclusively for measuring execution durations.

Fixes #12680

@palpant-dbx palpant-dbx marked this pull request as ready for review May 12, 2023 02:59
@github-actions github-actions bot added the awaiting-review PR is awaiting review from an assigned reviewer label May 12, 2023
@Pavank1992 Pavank1992 added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label May 12, 2023
@sluongng
Copy link
Contributor

#18347 is semi-related to the problem described in this PR as well.

@meteorcloudy meteorcloudy added team-Core Skyframe, bazel query, BEP, options parsing, bazelrc and removed team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website labels May 16, 2023
@palpant-dbx
Copy link
Author

Looks like this change was implemented in e67f648

@palpant-dbx palpant-dbx closed this Sep 6, 2023
@palpant-dbx palpant-dbx deleted the macos-monotonic-time branch September 6, 2023 18:36
@github-actions github-actions bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Core Skyframe, bazel query, BEP, options parsing, bazelrc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERROR: While parsing option --startup_time=18446744073709551598: '18446744073709551598' is not a long
4 participants