aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime2.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-01-13 12:17:26 -0800
committerIan Lance Taylor <iant@golang.org>2020-01-14 19:54:20 +0000
commitcfe3cd903f018dec3cb5997d53b1744df4e53909 (patch)
treee685f5fa8ca0df1bd74b2c2a634a3b70dc276deb /src/runtime/runtime2.go
parent71154e061f067a668e7b619d7b3701470b8561be (diff)
downloadgo-cfe3cd903f018dec3cb5997d53b1744df4e53909.tar.gz
go-cfe3cd903f018dec3cb5997d53b1744df4e53909.zip
runtime: keep P's first timer when in new atomically accessed field
This reduces lock contention when only a few P's are running and checking for whether they need to run timers on the sleeping P's. Without this change the running P's would get lock contention while looking at the sleeping P's timers. With this change a single atomic load suffices to determine whether there are any ready timers. Change-Id: Ie843782bd56df49867a01ecf19c47498ec827452 Reviewed-on: https://go-review.googlesource.com/c/go/+/214185 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/runtime/runtime2.go')
-rw-r--r--src/runtime/runtime2.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go
index 10d8d8c043..97f0f7a662 100644
--- a/src/runtime/runtime2.go
+++ b/src/runtime/runtime2.go
@@ -613,6 +613,11 @@ type p struct {
_ uint32 // Alignment for atomic fields below
+ // The when field of the first entry on the timer heap.
+ // This is updated using atomic functions.
+ // This is 0 if the timer heap is empty.
+ timer0When uint64
+
// Per-P GC state
gcAssistTime int64 // Nanoseconds in assistAlloc
gcFractionalMarkTime int64 // Nanoseconds in fractional mark worker (atomic)