summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@tailscale.com>2023-08-10 22:18:11 -0700
committerBrad Fitzpatrick <brad@danga.com>2023-08-11 13:23:16 -0700
commita1b8d703d62d1419a2dcf79c9c1aa955fec101ff (patch)
tree83f9c9adca9eac98700012799230f233f6096a80
parentcc3caa4b2ac3e102c453f4268d288183e4cba693 (diff)
downloadtailscale-a1b8d703d62d1419a2dcf79c9c1aa955fec101ff.tar.xz
tailscale-a1b8d703d62d1419a2dcf79c9c1aa955fec101ff.zip
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 <bradfitz@tailscale.com>
-rw-r--r--cmd/derper/depaware.txt2
-rw-r--r--cmd/tailscale/depaware.txt2
-rw-r--r--cmd/tailscaled/depaware.txt2
-rw-r--r--go.toolchain.rev2
-rw-r--r--tstime/mono/mono.go6
5 files changed, 5 insertions, 9 deletions
diff --git a/cmd/derper/depaware.txt b/cmd/derper/depaware.txt
index 1ee5a4757..3e99538eb 100644
--- a/cmd/derper/depaware.txt
+++ b/cmd/derper/depaware.txt
@@ -116,7 +116,7 @@ tailscale.com/cmd/derper dependencies: (generated by github.com/tailscale/depawa
tailscale.com/tka from tailscale.com/client/tailscale+
W tailscale.com/tsconst from tailscale.com/net/interfaces
tailscale.com/tstime from tailscale.com/derp+
- 💣 tailscale.com/tstime/mono from tailscale.com/tstime/rate
+ tailscale.com/tstime/mono from tailscale.com/tstime/rate
tailscale.com/tstime/rate from tailscale.com/wgengine/filter+
tailscale.com/tsweb from tailscale.com/cmd/derper
tailscale.com/tsweb/promvarz from tailscale.com/tsweb
diff --git a/cmd/tailscale/depaware.txt b/cmd/tailscale/depaware.txt
index c817e4198..cf02c0b65 100644
--- a/cmd/tailscale/depaware.txt
+++ b/cmd/tailscale/depaware.txt
@@ -114,7 +114,7 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
tailscale.com/tka from tailscale.com/client/tailscale+
W tailscale.com/tsconst from tailscale.com/net/interfaces
tailscale.com/tstime from tailscale.com/control/controlhttp+
- 💣 tailscale.com/tstime/mono from tailscale.com/tstime/rate
+ tailscale.com/tstime/mono from tailscale.com/tstime/rate
tailscale.com/tstime/rate from tailscale.com/wgengine/filter+
tailscale.com/types/dnstype from tailscale.com/tailcfg
tailscale.com/types/empty from tailscale.com/ipn
diff --git a/cmd/tailscaled/depaware.txt b/cmd/tailscaled/depaware.txt
index a090a8919..a20495608 100644
--- a/cmd/tailscaled/depaware.txt
+++ b/cmd/tailscaled/depaware.txt
@@ -296,7 +296,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
W tailscale.com/tsconst from tailscale.com/net/interfaces
tailscale.com/tsd from tailscale.com/cmd/tailscaled+
tailscale.com/tstime from tailscale.com/wgengine/magicsock+
- 💣 tailscale.com/tstime/mono from tailscale.com/net/tstun+
+ tailscale.com/tstime/mono from tailscale.com/net/tstun+
tailscale.com/tstime/rate from tailscale.com/wgengine/filter+
tailscale.com/tsweb/varz from tailscale.com/cmd/tailscaled
tailscale.com/types/dnstype from tailscale.com/ipn/ipnlocal+
diff --git a/go.toolchain.rev b/go.toolchain.rev
index d85d13a92..3ebe8b5e2 100644
--- a/go.toolchain.rev
+++ b/go.toolchain.rev
@@ -1 +1 @@
-593313088f6e5297cba5d5e3f392f15251bd5915
+27f103a44f8fd34a2cc36995ce7bf83d04433ead
diff --git a/tstime/mono/mono.go b/tstime/mono/mono.go
index 4042c53a5..260e02b0f 100644
--- a/tstime/mono/mono.go
+++ b/tstime/mono/mono.go
@@ -16,7 +16,6 @@ import (
"fmt"
"sync/atomic"
"time"
- _ "unsafe" // for go:linkname
)
// Time is the number of nanoseconds elapsed since an unspecified reference start time.
@@ -29,7 +28,7 @@ func Now() Time {
// The corresponding package time expression never does, if the wall clock is correct.
// Preserve this correspondence by increasing the "base" monotonic clock by a fair amount.
const baseOffset int64 = 1 << 55 // approximately 10,000 hours in nanoseconds
- return Time(now() + baseOffset)
+ return Time(int64(time.Since(baseWall)) + baseOffset)
}
// Since returns the time elapsed since t.
@@ -72,9 +71,6 @@ func (t *Time) LoadAtomic() Time {
return Time(atomic.LoadInt64((*int64)(t)))
}
-//go:linkname now runtime.nanotime1
-func now() int64
-
// baseWall and baseMono are a pair of almost-identical times used to correlate a Time with a wall time.
var (
baseWall time.Time