]> Cypherpunks repositories - gostls13.git/commit
runtime: bound defer pools (try 2)
authorDmitry Vyukov <dvyukov@google.com>
Thu, 5 Feb 2015 13:35:41 +0000 (13:35 +0000)
committerDmitry Vyukov <dvyukov@google.com>
Wed, 4 Mar 2015 14:29:58 +0000 (14:29 +0000)
commitb759e225f5c0ba1d672922e562cd52a131fd6d62
tree69286338ef936610348d26cb144b026db9c8eb0c
parent5ef145c8099cc28ce4e41ecb7c6883041f68df04
runtime: bound defer pools (try 2)

The unbounded list-based defer pool can grow infinitely.
This can happen if a goroutine routinely allocates a defer;
then blocks on one P; and then unblocked, scheduled and
frees the defer 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 defer pool; local pools become fixed-size
with the only purpose of amortizing accesses to the
central pool.

Freedefer now executes on system stack to not consume
nosplit stack space.

Change-Id: I1a27695838409259d1586a0adfa9f92bccf7ceba
Reviewed-on: https://go-review.googlesource.com/3967
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
src/runtime/mgc.go
src/runtime/panic.go
src/runtime/proc1.go
src/runtime/runtime2.go