• Austin Clements's avatar
    runtime: assist before allocating · 65aa2da6
    Austin Clements authored
    Currently, when the mutator allocates, the runtime first allocates the
    memory and then, if that G has done "enough" allocation, the runtime
    checks whether the G has assist debt to pay off and, if so, pays it
    off. This approach leads to under-assisting, where a G can allocate a
    large region (or many small regions) before paying for it, or can even
    exit with outstanding debt.
    
    This commit flips this around so that a G always acquires enough
    credit for an allocation before it can perform that allocation. We
    continue to amortize the cost of assists by requiring that they
    over-assist when triggered to build up credit for many allocations.
    
    Fixes #11967.
    
    Change-Id: Idac9f11133b328535667674d837be72c23ebd899
    Reviewed-on: https://go-review.googlesource.com/15409Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
    Run-TryBot: Austin Clements <austin@google.com>
    65aa2da6
mgc.go 59.5 KB