]> Cypherpunks repositories - gostls13.git/commit
runtime: eliminate _Psyscall
authorMichael Anthony Knyszek <mknyszek@google.com>
Sun, 2 Feb 2025 19:50:39 +0000 (19:50 +0000)
committerGopher Robot <gobot@golang.org>
Thu, 30 Oct 2025 17:08:55 +0000 (10:08 -0700)
commit7244e9221ff25b0c93a13ad8f1aa8917ca50f697
treee6fb8794933dca05c72b7571008982815027b0ac
parent5ef19c0d0c870cc014ba28aa13b926c13ec1063a
runtime: eliminate _Psyscall

This change eliminates the _Psyscall state by using synchronization on
the G status _Gsyscall to make syscalls work instead. This removes an
atomic Store and an atomic CAS on the syscall path, which reduces
syscall and cgo overheads. It also simplifies the syscall paths quite a
bit.

The one danger with this change is that we have a new combination of
states that was previously impossible. There are brief windows where
it's possible to observe a goroutine in _Grunning but without a P. This
change is careful to hide this detail from the execution tracer, but it
may have unexpected effects in the rest of the runtime, making this
change somewhat risky.

goos: linux
goarch: amd64
pkg: internal/runtime/cgobench
cpu: AMD EPYC 7B13
                   │ before.out  │             after.out              │
                   │   sec/op    │   sec/op     vs base               │
CgoCall-64           43.69n ± 1%   35.83n ± 1%  -17.99% (p=0.002 n=6)
CgoCallParallel-64   5.306n ± 1%   5.338n ± 1%        ~ (p=0.132 n=6)

Change-Id: I4551afc1eea0c1b67a0b2dd26b0d49aa47bf1fb8
Reviewed-on: https://go-review.googlesource.com/c/go/+/646198
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
12 files changed:
src/runtime/crash_test.go
src/runtime/heapdump.go
src/runtime/metrics.go
src/runtime/mprof.go
src/runtime/mstats.go
src/runtime/os_windows.go
src/runtime/preempt.go
src/runtime/proc.go
src/runtime/runtime2.go
src/runtime/traceevent.go
src/runtime/traceruntime.go
src/runtime/tracestatus.go