]> Cypherpunks repositories - gostls13.git/commit
time: optimize Now on darwin, windows
authorRuss Cox <rsc@golang.org>
Sat, 4 Feb 2017 00:26:13 +0000 (19:26 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 9 Feb 2017 14:45:16 +0000 (14:45 +0000)
commite4371fb179ad69cbd057f2430120843948e09f2f
tree4e49771324f1f6bd35b2b962a9511fb9bb071455
parent3a6842a0ecf66cf06ce4f0a5fcb9c09fbfdbecc1
time: optimize Now on darwin, windows

Fetch both monotonic and wall time together when possible.
Avoids skew and is cheaper.

Also shave a few ns off in conversion in package time.

Compared to current implementation (after monotonic changes):

name   old time/op  new time/op  delta
Now    19.6ns ± 1%   9.7ns ± 1%  -50.63%  (p=0.000 n=41+49) darwin/amd64
Now    23.5ns ± 4%  10.6ns ± 5%  -54.61%  (p=0.000 n=30+28) windows/amd64
Now    54.5ns ± 5%  29.8ns ± 9%  -45.40%  (p=0.000 n=27+29) windows/386

More importantly, compared to Go 1.8:

name   old time/op  new time/op  delta
Now     9.5ns ± 1%   9.7ns ± 1%   +1.94%  (p=0.000 n=41+49) darwin/amd64
Now    12.9ns ± 5%  10.6ns ± 5%  -17.73%  (p=0.000 n=30+28) windows/amd64
Now    15.3ns ± 5%  29.8ns ± 9%  +94.36%  (p=0.000 n=30+29) windows/386

This brings time.Now back in line with Go 1.8 on darwin/amd64 and windows/amd64.

It's not obvious why windows/386 is still noticeably worse than Go 1.8,
but it's better than before this CL. The windows/386 speed is not too
important; the changes just keep the two architectures similar.

Change-Id: If69b94970c8a1a57910a371ee91e0d4e82e46c5d
Reviewed-on: https://go-review.googlesource.com/36428
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
15 files changed:
src/runtime/heapdump.go
src/runtime/mgc.go
src/runtime/mstats.go
src/runtime/os_windows.go
src/runtime/proc.go
src/runtime/stubs.go
src/runtime/sys_darwin_386.s
src/runtime/sys_darwin_amd64.s
src/runtime/sys_windows_386.s
src/runtime/sys_windows_amd64.s
src/runtime/time.go
src/runtime/timeasm.go [new file with mode: 0644]
src/runtime/timestub.go [new file with mode: 0644]
src/time/mono_test.go
src/time/time.go