]> Cypherpunks repositories - gostls13.git/commit
runtime: assist before allocating
authorAustin Clements <austin@google.com>
Mon, 5 Oct 2015 03:56:11 +0000 (20:56 -0700)
committerAustin Clements <austin@google.com>
Fri, 9 Oct 2015 19:39:03 +0000 (19:39 +0000)
commit65aa2da61793846b9929c239dcbdb266490335e5
treea0d532c7f8256a304ab3c3189d808e5a0881a2b8
parent89c341c5e969b571a9475b263b237a8a25efd76b
runtime: assist before allocating

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/15409
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
src/runtime/malloc.go
src/runtime/mgc.go
src/runtime/mgcmark.go