• Dmitry Vyukov's avatar
    runtime: bound defer pools · 80590711
    Dmitry Vyukov authored
    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.
    
    Change-Id: Iadcfb113ccecf912e1b64afc07926f0de9de2248
    Reviewed-on: https://go-review.googlesource.com/3741Reviewed-by: 's avatarKeith Randall <khr@golang.org>
    80590711
mgc0.go 2.2 KB