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>
// 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
// 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 {