diff options
| author | Austin Clements <austin@google.com> | 2016-04-16 18:27:38 -0400 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2016-04-21 20:07:17 +0000 |
| commit | 479501c14c9d36e27727bc4b4294d57c5ddc29d0 (patch) | |
| tree | 9eb30469d54d57e05aff9e906e08695ff227d43b /src/runtime/malloc.go | |
| parent | a683c385ad874b0066787dc010cacba8aaff894c (diff) | |
| download | go-479501c14c9d36e27727bc4b4294d57c5ddc29d0.tar.xz | |
runtime: count black allocations toward scan work
Currently we count black allocations toward the scannable heap size,
but not toward the scan work we've done so far. This is clearly
inconsistent (we have, in effect, scanned these allocations and since
they're already black, we're not going to scan them again). Worse, it
means we don't count black allocations toward the scannable heap size
as of the *next* GC because this is based on the amount of scan work
we did in this cycle.
Fix this by counting black allocations as scan work. Currently the GC
spends very little time in allocate-black mode, so this probably
hasn't been a problem, but this will become important when we switch
to always allocating black.
Change-Id: If6ff693b070c385b65b6ecbbbbf76283a0f9d990
Reviewed-on: https://go-review.googlesource.com/22119
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/malloc.go')
| -rw-r--r-- | src/runtime/malloc.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 30f2a4fca5..3f437bc02f 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -655,6 +655,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { size = s.elemsize } + var scanSize uintptr if noscan { // All objects are pre-marked as noscan. Nothing to do. } else { @@ -673,11 +674,12 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { // pointers, GC has to scan to the last // element. if typ.ptrdata != 0 { - c.local_scan += dataSize - typ.size + typ.ptrdata + scanSize = dataSize - typ.size + typ.ptrdata } } else { - c.local_scan += typ.ptrdata + scanSize = typ.ptrdata } + c.local_scan += scanSize // Ensure that the stores above that initialize x to // type-safe memory and set the heap bits occur before @@ -694,7 +696,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { // a race marking the bit. if gcphase == _GCmarktermination || gcBlackenPromptly { systemstack(func() { - gcmarknewobject_m(uintptr(x), size) + gcmarknewobject_m(uintptr(x), size, scanSize) }) } |
