aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime2.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2015-12-08 15:11:27 +0100
committerDmitry Vyukov <dvyukov@google.com>2015-12-11 11:31:12 +0000
commitfb6f8a96f24f6b30e99cc77d78bc0194ffec7a41 (patch)
tree4f407ee25a38172dacb825259c48a435549c8c23 /src/runtime/runtime2.go
parent8545ea9cee087fd0fbac41bba7616d2fc4f2bc19 (diff)
downloadgo-fb6f8a96f24f6b30e99cc77d78bc0194ffec7a41.tar.xz
runtime: remove unnecessary wakeups of worker threads
Currently we wake up new worker threads whenever we pass through the scheduler with nmspinning==0. This leads to lots of unnecessary thread wake ups. Instead let only spinning threads wake up new spinning threads. For the following program: package main import "runtime" func main() { for i := 0; i < 1e7; i++ { runtime.Gosched() } } Before: $ time ./test real 0m4.278s user 0m7.634s sys 0m1.423s $ strace -c ./test % time seconds usecs/call calls errors syscall 99.93 9.314936 3 2685009 17536 futex After: $ time ./test real 0m1.200s user 0m1.181s sys 0m0.024s $ strace -c ./test % time seconds usecs/call calls errors syscall 3.11 0.000049 25 2 futex Fixes #13527 Change-Id: Ia1f5bf8a896dcc25d8b04beb1f4317aa9ff16f74 Reviewed-on: https://go-review.googlesource.com/17540 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Dmitry Vyukov <dvyukov@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/runtime2.go')
-rw-r--r--src/runtime/runtime2.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go
index cfe4589448..86ed846064 100644
--- a/src/runtime/runtime2.go
+++ b/src/runtime/runtime2.go
@@ -419,7 +419,7 @@ type schedt struct {
pidle puintptr // idle p's
npidle uint32
- nmspinning uint32 // limited to [0, 2^31-1]
+ nmspinning uint32 // See "Worker thread parking/unparking" comment in proc.go.
// Global runnable queue.
runqhead guintptr