[HN Gopher] Monotonic and wall clock time in the Go time package
___________________________________________________________________
Monotonic and wall clock time in the Go time package
Author : valyala
Score : 14 points
Date : 2025-07-25 18:05 UTC (4 hours ago)
(HTM) web link (victoriametrics.com)
(TXT) w3m dump (victoriametrics.com)
| deepsun wrote:
| And not a word about fasttime.UnixTimestamp()? I thought that's
| the recommended way, it literally says: // It
| is faster than time.Now().Unix()
|
| https://pkg.go.dev/github.com/VictoriaMetrics/VictoriaMetric...
| deepsun wrote:
| Wait, I see it's been removed actually [1]. Why, isn't it
| faster anymore?
|
| [1]
| https://github.com/VictoriaMetrics/VictoriaMetrics/commit/c2...
| noselasd wrote:
| It's not removed, it's moved to a separate file as it's
| problematic to use in tests, commit 06c2631 talks about why.
| noselasd wrote:
| It's a bit specialized though, it's just a cached value of a
| time.NewTicker updating once per second and the article talks
| about this in the "Schedule Based on Monotonic Time" section
| kiitos wrote:
| This package spawns a goroutine that updates an atomic value
| every second based on a time.Time from a time.Ticker, and its
| functions load that atomic value. This is not really comparable
| to anything in package time in any useful way...
| jsw wrote:
| For simple high-frequency time deltas, I've found this function
| wins on the perf front: //go:linkname nanotime
| runtime.nanotime func nanotime() int64
___________________________________________________________________
(page generated 2025-07-25 23:01 UTC)