Get rid of go:linkname for nanotime #1262

Closed
opened 2024-07-22 12:33:17 +00:00 by fyrchik · 1 comment
Owner

We use it for runtime.nanotime to get monotonic time in the sdnotify (#1137). After go1.23 linkname will cease to work for certain scenarios. Even though, runtime.nanotime is an explicit exception, I would rather NOT be clever in a random non-critical piece of code.
Stdlib comment to nanotime offers a simple alternative.

From 9a3ef86173 (diff-859519df541485f8bd470481b752641b91a0aae638218cf4ccaea0a8677b879fR17) :

// Many external packages linkname nanotime to get a fast monotonic time.
// Such code should be updated to use:
//
//	var start = time.Now() // at init time
//
// and then replace nanotime() with time.Since(start), which is equally fast.
//
// However, all the code linknaming nanotime is never going to go away.
We use it for `runtime.nanotime` to get monotonic time in the sdnotify (#1137). After go1.23 `linkname` will cease to work for certain scenarios. Even though, `runtime.nanotime` is an explicit exception, I would rather NOT be clever in a random non-critical piece of code. Stdlib comment to nanotime offers a simple alternative. From https://github.com/golang/go/commit/9a3ef861732031dc70794531452922d70855e27a#diff-859519df541485f8bd470481b752641b91a0aae638218cf4ccaea0a8677b879fR17 : ``` // Many external packages linkname nanotime to get a fast monotonic time. // Such code should be updated to use: // // var start = time.Now() // at init time // // and then replace nanotime() with time.Since(start), which is equally fast. // // However, all the code linknaming nanotime is never going to go away. ```
fyrchik added the
frostfs-node
frostfs-ir
labels 2024-07-22 12:33:46 +00:00
fyrchik added the
internal
label 2024-07-23 06:06:07 +00:00
elebedeva self-assigned this 2024-07-23 07:37:09 +00:00
fyrchik added this to the v0.43.0 milestone 2024-07-23 07:53:53 +00:00
Author
Owner
https://github.com/coreos/go-systemd/pull/435/
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#1262
No description provided.