• Dmitry Vyukov's avatar
    runtime: bound sudog cache · 5ef145c8
    Dmitry Vyukov authored
    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/3742Reviewed-by: 's avatarKeith Randall <khr@golang.org>
    Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
    5ef145c8
mcache.go 4.02 KB