Skip to content

Commit a543713

Browse files
committed
Provide temporary fallback for Snotime via time.Now() on linux/amd64/go1.17 due to Go's assembly implementation being removed on this target.
This is a (hopefully temporary) performance regression on this target: the call involves getting the monotonic clock time and back-and-forth conversions while we only need the wall clock time, which is what runtime.walltime1 used to provide. However, the removal from the runtime package necessitates backporting a significant portion of Go's runtime assembly for this target, where the previous bypass to achieve the perf boost over time.Now() was trivial in comparison, so I decided against maintaining such backport and will look into a more manageable solution instead.
1 parent 9f4b669 commit a543713

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

internal/time.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// +build !windows,!amd64
1+
//go:build !(windows && amd64) && !(linux && amd64 && go1.17)
2+
// +build !windows !amd64
3+
// +build !linux !amd64 !go1.17
24

35
package internal
46

internal/time_linux_amd64.go

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//go:build go1.17
2+
// +build go1.17
3+
4+
package internal
5+
6+
import "time"
7+
8+
// Snotime returns the current wall clock time reported by the OS as adjusted to our internal epoch.
9+
func Snotime() uint64 {
10+
return uint64(time.Now().UnixNano()-epochNsec) / timeUnit
11+
}

0 commit comments

Comments
 (0)