• Austin Clements's avatar
    runtime: don't rescan finalizers queue during mark termination · f1ba75f8
    Austin Clements authored
    Currently we scan the finalizers queue both during concurrent mark and
    during mark termination. This costs roughly 20ns per queued finalizer
    and about 1ns per unused finalizer queue slot (allocated queue length
    never decreases), which can drive up STW time if there are many
    finalizers.
    
    However, we only add finalizers to this queue during sweeping, which
    means that the second scan will never find anything new. Hence, we can
    fix this by simply not scanning the finalizers queue during mark
    termination. This brings the STW time under the 100µs goal even with
    1,000,000 queued finalizers.
    
    Fixes #18869.
    
    Change-Id: I4ce5620c66fb7f13ebeb39ca313ce57047d1d0fb
    Reviewed-on: https://go-review.googlesource.com/36013
    Run-TryBot: Austin Clements <austin@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
    f1ba75f8
mgcmark.go 41.6 KB