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

Fix underlying time source for Time.nanos() on macOS #3921

Merged
merged 1 commit into from
Nov 13, 2021

Conversation

ergl
Copy link
Member

@ergl ergl commented Nov 13, 2021

Previously, we were using mach_absolute_time on macOS to get the number of ticks since boot, with the assumption that ticks increment at nanosecond intervals. However, as noted by Apple, this assumption is flawed on Apple Silicon, and will also affect any binaries that were built on Intel, as the Rosetta 2 translator will not apply any time conversion.

The recommended replacement to mach_absolute_time is to use clock_gettime_nsec_np with a clock of type CLOCK_UPTIME_RAW.

Joe already applied this fix to cpu.c on 197b952, but we missed the call to mach_absolute_time on time.pony

Joe already applied this fix to cpu.c on
197b952, but we missed the call to
mach_absolute_time on time.pony
@ergl ergl added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Nov 13, 2021
@ergl
Copy link
Member Author

ergl commented Nov 13, 2021

When this is merged, we should add a note to LWIP so that others running on Apple Silicon have a chance to upgrade, since this affects the behaviour of timers.

@ergl ergl requested a review from jemc November 13, 2021 12:07
@SeanTAllen SeanTAllen merged commit 9ef833a into main Nov 13, 2021
@SeanTAllen SeanTAllen deleted the ergl/fix_time_nanos branch November 13, 2021 12:31
github-actions bot pushed a commit that referenced this pull request Nov 13, 2021
github-actions bot pushed a commit that referenced this pull request Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants