diff options
| author | Michael Anthony Knyszek <mknyszek@google.com> | 2021-11-11 18:12:20 +0000 |
|---|---|---|
| committer | Michael Knyszek <mknyszek@google.com> | 2021-11-15 17:10:25 +0000 |
| commit | f986191325e9c8be606b5f4db69a33692728274b (patch) | |
| tree | 046442fa61ddc727f41b85240e9f0f54fa704b9c /src | |
| parent | ce4a2755956a42aa3211c121139a52c9a97a9aa0 (diff) | |
| download | go-f986191325e9c8be606b5f4db69a33692728274b.tar.xz | |
runtime: fix released bytes accumulation in bg scavenger
Currently "released" is not accumulated bytes released. If the last
attempt to scavenge ends up as 0, then the scavenger will go to sleep
too soon. This is an artifact from the old code where scavenge would
only be called into once.
Change-Id: I85aa2261f1504a6fb5bf086daa029eecb0e09cf4
Reviewed-on: https://go-review.googlesource.com/c/go/+/363416
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/runtime/mgcscavenge.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/runtime/mgcscavenge.go b/src/runtime/mgcscavenge.go index 4a7f2465fd..286aa1bbae 100644 --- a/src/runtime/mgcscavenge.go +++ b/src/runtime/mgcscavenge.go @@ -326,8 +326,8 @@ func bgscavenge(c chan int) { // Accumulate the amount of time spent scavenging. start := nanotime() - released = mheap_.pages.scavenge(scavengeQuantum) - atomic.Xadduintptr(&mheap_.pages.scav.released, released) + r := mheap_.pages.scavenge(scavengeQuantum) + atomic.Xadduintptr(&mheap_.pages.scav.released, r) end := nanotime() // On some platforms we may see end >= start if the time it takes to scavenge @@ -339,10 +339,11 @@ func bgscavenge(c chan int) { // on timing. const approxCritNSPerPhysicalPage = 10e3 if end <= start { - crit += approxCritNSPerPhysicalPage * float64(released/physPageSize) + crit += approxCritNSPerPhysicalPage * float64(r/physPageSize) } else { crit += float64(end - start) } + released += r } if released == 0 { |
