]> Cypherpunks repositories - gostls13.git/commit
runtime: measure speed of procyield and osyield
authorRhys Hiltner <rhys.hiltner@gmail.com>
Fri, 26 Jul 2024 17:14:20 +0000 (10:14 -0700)
committerEmmanuel Odeke <emmanuel@orijtech.com>
Thu, 1 Aug 2024 03:06:18 +0000 (03:06 +0000)
commit6ac87aa5b36e7a9389754cf5569af94447266b47
treee0b975c08047cafaca8e0a651d9a4b1ec58d1cb7
parentbd85a3b1535928bcdc9bb4512f3dd9048de14617
runtime: measure speed of procyield and osyield

These are delay primitives for lock2. If a mutex isn't immediately
available, we can use procyield to tell the processor to wait for a
moment, or osyield to allow the OS to run a different process or thread
if one is waiting. We expect a processor-level yield to be faster than
an os-level yield, and for both of them to be fast relative to entering
a full sleep (via futexsleep or semasleep).

Each architecture has its own way of hinting to the processor that it's
in a spin-wait loop, so procyield presents an architecture-independent
interface for use in lock_futex.go and lock_sema.go.

Measure the (single-threaded) speed of these to confirm.

For #68578

Change-Id: I90cd46ea553f2990395aceb048206285558c877e
Reviewed-on: https://go-review.googlesource.com/c/go/+/601396
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/runtime/export_test.go
src/runtime/runtime_test.go