• Austin Clements's avatar
    runtime: remove sweep wait loop in finishsweep_m · 9a31d38f
    Austin Clements authored
    In general, finishsweep_m must block until any spans that are
    concurrently being swept have been swept. It accomplishes this by
    looping over all spans, which, as in the previous commit, takes
    ~1ms/heap GB. Unfortunately, we do this during the STW sweep
    termination phase, so multi-gigabyte heaps can push our STW time past
    10ms.
    
    However, there's no need to do this wait if the world is stopped
    because, in effect, stopping the world already had to wait for
    anything that was sweeping (and if it didn't, the wait in
    finishsweep_m would deadlock). Hence, we can simply skip this loop if
    the world is stopped, such as during sweep termination. In fact,
    currently all calls to finishsweep_m are STW, but this hasn't always
    been the case and may not be the case in the future, so we keep the
    logic around.
    
    For 24GB heaps, this reduces max pause time by 75% relative to tip and
    by 90% relative to Go 1.5. Notably, all pauses are now well under
    10ms. Here are the results for the garbage benchmark:
    
                   ------------- max pause ------------
    Heap   Procs   after change   before change   1.5.1
    24GB     12        3.8ms          16ms         37ms
    24GB      4        3.7ms          16ms         37ms
     4GB      4        3.7ms           3ms        6.9ms
    
    In the 4GB/4P case, it seems the "before change" run got lucky: the
    max went up, but the 99%ile pause time went down from 3ms to 2.04ms.
    
    Change-Id: Ica22189559f231d408ef2815019c9dbb5f38bf31
    Reviewed-on: https://go-review.googlesource.com/15071Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
    Run-TryBot: Austin Clements <austin@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    9a31d38f
mgcsweep.go 10.7 KB