aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mcentral.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2017-04-03 15:22:06 -0400
committerAustin Clements <austin@google.com>2017-04-21 17:41:57 +0000
commita5eb3dceaf8d4e3fafac0d947decae62d3028df1 (patch)
treea71f8db01608d68a32abaf14a26581fae5634234 /src/runtime/mcentral.go
parentee175afac237c9fcb54785eec2890dfb0dd6825f (diff)
downloadgo-a5eb3dceaf8d4e3fafac0d947decae62d3028df1.tar.gz
go-a5eb3dceaf8d4e3fafac0d947decae62d3028df1.zip
runtime: drive proportional sweep directly off heap_live
Currently, proportional sweep maintains its own count of how many bytes have been allocated since the beginning of the sweep cycle so it can compute how many pages need to be swept for a given allocation. However, this requires a somewhat complex reimbursement scheme since proportional sweep must be done before a span is allocated, but we don't know how many bytes to charge until we've allocated a span. This means that the allocated byte count used by proportional sweep can go up and down, which has led to underflow bugs in the past (#18043) and is going to interfere with adjusting sweep pacing on-the-fly (for #19076). This approach also means we're maintaining a statistic that is very closely related to heap_live, but has a different 0 value. This is particularly confusing because the sweep ratio is computed based on heap_live, so you have to understand that these two statistics are very closely related. Replace all of this and compute the sweep debt directly from the current value of heap_live. To make this work, we simply save the value of heap_live when the sweep ratio is computed to use as a "basis" for later computing the sweep debt. This eliminates the need for reimbursement as well as the code for maintaining the sweeper's version of the live heap size. For #19076. Coincidentally fixes #18043, since this eliminates sweep reimbursement entirely. Change-Id: I1f931ddd6e90c901a3972c7506874c899251dc2a Reviewed-on: https://go-review.googlesource.com/39832 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/runtime/mcentral.go')
-rw-r--r--src/runtime/mcentral.go3
1 files changed, 0 insertions, 3 deletions
diff --git a/src/runtime/mcentral.go b/src/runtime/mcentral.go
index 8f9c529539..5302dd8e3d 100644
--- a/src/runtime/mcentral.go
+++ b/src/runtime/mcentral.go
@@ -126,9 +126,6 @@ havespan:
// mcache. If it gets uncached, we'll adjust this.
atomic.Xadd64(&c.nmalloc, int64(n))
usedBytes := uintptr(s.allocCount) * s.elemsize
- if usedBytes > 0 {
- reimburseSweepCredit(usedBytes)
- }
atomic.Xadd64(&memstats.heap_live, int64(spanBytes)-int64(usedBytes))
if trace.enabled {
// heap_live changed.