diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2015-02-03 00:33:02 +0300 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2015-03-04 14:14:29 +0000 |
| commit | 5ef145c8099cc28ce4e41ecb7c6883041f68df04 (patch) | |
| tree | b8409241efc9768cbd80969e7c388b6d66e4d873 /src/runtime/runtime2.go | |
| parent | 60b8908588eb60b7e0d2053e52d191987a868c74 (diff) | |
| download | go-5ef145c8099cc28ce4e41ecb7c6883041f68df04.tar.xz | |
runtime: bound sudog cache
The unbounded list-based sudog cache can grow infinitely.
This can happen if a goroutine is routinely blocked on one P
and then unblocked and scheduled on another P.
The scenario was reported on golang-nuts list.
We've been here several times. Any unbounded local caches
are bad and grow to infinite size. This change introduces
central sudog cache; local caches become fixed-size
with the only purpose of amortizing accesses to the
central cache.
The change required to move sudog cache from mcache to P,
because mcache is not scanned by GC.
Change-Id: I3bb7b14710354c026dcba28b3d3c8936a8db4e90
Reviewed-on: https://go-review.googlesource.com/3742
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
Diffstat (limited to 'src/runtime/runtime2.go')
| -rw-r--r-- | src/runtime/runtime2.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index ea2d55dbb6..81d39fb48e 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -329,6 +329,9 @@ type p struct { gfree *g gfreecnt int32 + sudogcache []*sudog + sudogbuf [128]*sudog + tracebuf *traceBuf pad [64]byte @@ -365,6 +368,10 @@ type schedt struct { gfree *g ngfree int32 + // Central cache of sudog structs. + sudoglock mutex + sudogcache *sudog + gcwaiting uint32 // gc is waiting to run stopwait int32 stopnote note |
