Skip to content

Commit a1b8d70

Browse files
committed
tstime/mono: remove unsafe
This removes the unsafe/linkname and only uses the standard library. It's a bit slower, for now, but https://go.dev/cl/518336 should get us back. On darwin/arm64, without https://go.dev/cl/518336 pkg: tailscale.com/tstime/mono │ before │ after │ │ sec/op │ sec/op vs base │ MonoNow-8 16.20n ± 0% 19.75n ± 0% +21.92% (p=0.000 n=10) TimeNow-8 39.46n ± 0% 39.40n ± 0% -0.16% (p=0.002 n=10) geomean 25.28n 27.89n +10.33% And with it, MonoNow-8 16.34n ± 1% 16.93n ± 0% +3.67% (p=0.001 n=10) TimeNow-8 39.55n ± 15% 38.46n ± 1% -2.76% (p=0.000 n=10) geomean 25.42n 25.52n +0.41% Updates #8839 Updates tailscale/go#70 Signed-off-by: Brad Fitzpatrick <[email protected]>
1 parent cc3caa4 commit a1b8d70

5 files changed

Lines changed: 5 additions & 9 deletions

File tree

‎cmd/derper/depaware.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ tailscale.com/cmd/derper dependencies: (generated by github.com/tailscale/depawa
116116
tailscale.com/tka from tailscale.com/client/tailscale+
117117
W tailscale.com/tsconst from tailscale.com/net/interfaces
118118
tailscale.com/tstime from tailscale.com/derp+
119-
💣 tailscale.com/tstime/mono from tailscale.com/tstime/rate
119+
tailscale.com/tstime/mono from tailscale.com/tstime/rate
120120
tailscale.com/tstime/rate from tailscale.com/wgengine/filter+
121121
tailscale.com/tsweb from tailscale.com/cmd/derper
122122
tailscale.com/tsweb/promvarz from tailscale.com/tsweb

‎cmd/tailscale/depaware.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
114114
tailscale.com/tka from tailscale.com/client/tailscale+
115115
W tailscale.com/tsconst from tailscale.com/net/interfaces
116116
tailscale.com/tstime from tailscale.com/control/controlhttp+
117-
💣 tailscale.com/tstime/mono from tailscale.com/tstime/rate
117+
tailscale.com/tstime/mono from tailscale.com/tstime/rate
118118
tailscale.com/tstime/rate from tailscale.com/wgengine/filter+
119119
tailscale.com/types/dnstype from tailscale.com/tailcfg
120120
tailscale.com/types/empty from tailscale.com/ipn

‎cmd/tailscaled/depaware.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
296296
W tailscale.com/tsconst from tailscale.com/net/interfaces
297297
tailscale.com/tsd from tailscale.com/cmd/tailscaled+
298298
tailscale.com/tstime from tailscale.com/wgengine/magicsock+
299-
💣 tailscale.com/tstime/mono from tailscale.com/net/tstun+
299+
tailscale.com/tstime/mono from tailscale.com/net/tstun+
300300
tailscale.com/tstime/rate from tailscale.com/wgengine/filter+
301301
tailscale.com/tsweb/varz from tailscale.com/cmd/tailscaled
302302
tailscale.com/types/dnstype from tailscale.com/ipn/ipnlocal+

‎go.toolchain.rev‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
593313088f6e5297cba5d5e3f392f15251bd5915
1+
27f103a44f8fd34a2cc36995ce7bf83d04433ead

‎tstime/mono/mono.go‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"fmt"
1717
"sync/atomic"
1818
"time"
19-
_ "unsafe" // for go:linkname
2019
)
2120

2221
// Time is the number of nanoseconds elapsed since an unspecified reference start time.
@@ -29,7 +28,7 @@ func Now() Time {
2928
// The corresponding package time expression never does, if the wall clock is correct.
3029
// Preserve this correspondence by increasing the "base" monotonic clock by a fair amount.
3130
const baseOffset int64 = 1 << 55 // approximately 10,000 hours in nanoseconds
32-
return Time(now() + baseOffset)
31+
return Time(int64(time.Since(baseWall)) + baseOffset)
3332
}
3433

3534
// Since returns the time elapsed since t.
@@ -72,9 +71,6 @@ func (t *Time) LoadAtomic() Time {
7271
return Time(atomic.LoadInt64((*int64)(t)))
7372
}
7473

75-
//go:linkname now runtime.nanotime1
76-
func now() int64
77-
7874
// baseWall and baseMono are a pair of almost-identical times used to correlate a Time with a wall time.
7975
var (
8076
baseWall time.Time

0 commit comments

Comments
 (0)