]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: yield instead of sleeping in runqgrab on OpenBSD
authorMichael Anthony Knyszek <mknyszek@google.com>
Thu, 21 Apr 2022 22:18:31 +0000 (22:18 +0000)
committerMichael Knyszek <mknyszek@google.com>
Tue, 26 Apr 2022 22:08:12 +0000 (22:08 +0000)
OpenBSD has a coarse sleep granularity that rounds up to 10 ms
increments. This can cause significant STW delays, among other issues.
As far as I can tell, there's only 1 tightly timed sleep without an
explicit wakeup for which this actually matters.

Fixes #52475.

Change-Id: Ic69fc11096ddbbafd79b2dcdf3f912fde242db24
Reviewed-on: https://go-review.googlesource.com/c/go/+/401638
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/runtime/proc.go

index b281d9f3b8a49d1254fa91f9a7b2d99c5d9a867c..96d44efdddf30f73cf9d68b85a21f713d90db8e5 100644 (file)
@@ -5904,10 +5904,10 @@ func runqgrab(_p_ *p, batch *[256]guintptr, batchHead uint32, stealRunNextG bool
                                                // between different Ps.
                                                // A sync chan send/recv takes ~50ns as of time of
                                                // writing, so 3us gives ~50x overshoot.
-                                               if GOOS != "windows" {
+                                               if GOOS != "windows" && GOOS != "openbsd" {
                                                        usleep(3)
                                                } else {
-                                                       // On windows system timer granularity is
+                                                       // On some platforms system timer granularity is
                                                        // 1-15ms, which is way too much for this
                                                        // optimization. So just yield.
                                                        osyield()