From 1f354a60ff7e8e047e4dfecb1033a20ee8c266dc Mon Sep 17 00:00:00 2001 From: qmuntal Date: Mon, 11 Mar 2024 10:49:44 +0100 Subject: runtime: don't call lockOSThread for every syscall call on Windows Windows syscall.SyscallN currently calls lockOSThread for every syscall. This can be expensive and produce unnecessary context switches, especially when the syscall is called frequently under high contention. The lockOSThread was necessary to ensure that cgocall wouldn't reschedule the goroutine to a different M, as the syscall return values are reported back in the M struct. This CL instructs cgocall to copy the syscall return values into the the M that will see the caller on return, so the caller no longer needs to call lockOSThread. Updates #58336. Cq-Include-Trybots: luci.golang.try:gotip-windows-arm64,gotip-windows-amd64-longtest Change-Id: If6644fd111dbacab74e7dcee2afa18ca146735da Reviewed-on: https://go-review.googlesource.com/c/go/+/562915 Reviewed-by: Alex Brainman Auto-Submit: Emmanuel Odeke Reviewed-by: Than McIntosh TryBot-Result: Gopher Robot Reviewed-by: Michael Pratt Run-TryBot: Emmanuel Odeke LUCI-TryBot-Result: Go LUCI --- src/runtime/runtime2.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/runtime/runtime2.go') diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index 4a7ad27172..c335f8c9d0 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -612,11 +612,11 @@ type m struct { // these are here because they are too large to be on the stack // of low-level NOSPLIT functions. - libcall libcall - libcallpc uintptr // for cpu profiler - libcallsp uintptr - libcallg guintptr - syscall libcall // stores syscall parameters on windows + libcall libcall + libcallpc uintptr // for cpu profiler + libcallsp uintptr + libcallg guintptr + winsyscall winlibcall // stores syscall parameters on windows vdsoSP uintptr // SP for traceback while in VDSO call (0 if not in call) vdsoPC uintptr // PC for traceback while in VDSO call -- cgit v1.3-5-g9baa