Skip to content

runtime: use mach_absolute_time for runtime.nanotime #17610

@quentinmit

Description

@quentinmit

runtime.nanotime currently returns wallclock time, which means timers do not function correctly in the presence of NTP. We should use mach_absolute_time instead, which returns a monotonic nanoseconds-since-boot timer. (Officially, it returns time in "absolute time units" and you have to multiply by a constant to get nanoseconds. But the implementation of both mach_absolute_time and gettimeofday assume/document that it's really nanoseconds...)

This has the bonus of being much simpler than gettimeofday, so it will also reduce our chances of being hit by a change in the kernel ABI.

Targeting 1.9 because this seems too dangerous for 1.8.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions