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

runtime: use clock_gettime instead of gettimeofday on Darwin #25633

Closed
randall77 opened this issue May 29, 2018 · 6 comments
Closed

runtime: use clock_gettime instead of gettimeofday on Darwin #25633

randall77 opened this issue May 29, 2018 · 6 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Darwin
Milestone

Comments

@randall77
Copy link
Contributor

clock_gettime has higher resolution, we should use it if available.
It is not guaranteed to be available until Darwin 10.12. This issue is on hold until that is our minimum Darwin version.

We could do this now but it would require making the choice at runtime. That seems difficult - we'd need to use the Darwin equivalent of dlopen/dlsym to query the existence of, and call, clock_gettime.

@randall77 randall77 added OS-Darwin NeedsFix The path to resolution is known, but the work has not been done. labels May 29, 2018
@randall77 randall77 added this to the Go1.12 milestone May 29, 2018
@randall77 randall77 self-assigned this May 29, 2018
@randall77 randall77 modified the milestones: Go1.12, Unplanned Sep 19, 2018
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/161721 mentions this issue: unix: add ClockGettime on darwin/amd64

gopherbot pushed a commit to golang/sys that referenced this issue Feb 9, 2019
Updates golang/go#25633

Change-Id: I20ff2d0cda642fb7b155d3ae06499e8c0ef0a2b2
Reviewed-on: https://go-review.googlesource.com/c/161721
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@randall77
Copy link
Contributor Author

Go 1.13 requires Darwin 1.11 or newer. Getting closer...

@randall77
Copy link
Contributor Author

Go 1.15 will require 10.12. Setting that milestone.

@randall77 randall77 modified the milestones: Unplanned, Go1.15 Jan 30, 2020
@ianlancetaylor ianlancetaylor modified the milestones: Go1.15, Go1.16 May 19, 2020
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/270918 mentions this issue: runtime: use clock_gettime instead of gettimeofday on darwin

@bradfitz
Copy link
Contributor

@tklauser, any positive performance improvements as a result of this? I seem to recall another bug where getting the time on macOS was really slow for some reason.

@tklauser
Copy link
Member

@bradfitz I didn't see any performance improvements. The benchmarks seem more or less unchanged (macOS 10.15 on 1.6 GHz Dual-Core Intel Core i5):

name           old time/op  new time/op  delta
Now-4          83.3ns ± 4%  80.9ns ± 2%  -2.81%  (p=0.009 n=10+10)
NowUnixNano-4  85.3ns ± 4%  85.1ns ± 3%    ~     (p=1.000 n=10+10)

Results seems to be a bit inconsistent though, for some runs I also got slightly increased numbers (around +2%).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Darwin
Projects
None yet
Development

No branches or pull requests

5 participants