Commit 007e8a2f authored by Austin Clements's avatar Austin Clements

runtime: rename gosweepdone to isSweepDone and document better

gosweepdone is another anachronism from the time when the sweeper was
implemented in C. Rename it to "isSweepDone" for the modern era.

Change-Id: I8472aa6f52478459c3f2edc8a4b2761e73c4c2dd
Reviewed-on: https://go-review.googlesource.com/c/138658
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent f3bb4cbf
...@@ -789,7 +789,7 @@ func gcSetTriggerRatio(triggerRatio float64) { ...@@ -789,7 +789,7 @@ func gcSetTriggerRatio(triggerRatio float64) {
trigger = uint64(float64(memstats.heap_marked) * (1 + triggerRatio)) trigger = uint64(float64(memstats.heap_marked) * (1 + triggerRatio))
// Don't trigger below the minimum heap size. // Don't trigger below the minimum heap size.
minTrigger := heapminimum minTrigger := heapminimum
if !gosweepdone() { if !isSweepDone() {
// Concurrent sweep happens in the heap growth // Concurrent sweep happens in the heap growth
// from heap_live to gc_trigger, so ensure // from heap_live to gc_trigger, so ensure
// that concurrent sweep has some heap growth // that concurrent sweep has some heap growth
...@@ -834,7 +834,7 @@ func gcSetTriggerRatio(triggerRatio float64) { ...@@ -834,7 +834,7 @@ func gcSetTriggerRatio(triggerRatio float64) {
} }
// Update sweep pacing. // Update sweep pacing.
if gosweepdone() { if isSweepDone() {
mheap_.sweepPagesPerByte = 0 mheap_.sweepPagesPerByte = 0
} else { } else {
// Concurrent sweep needs to sweep all of the in-use // Concurrent sweep needs to sweep all of the in-use
......
...@@ -60,7 +60,7 @@ func bgsweep(c chan int) { ...@@ -60,7 +60,7 @@ func bgsweep(c chan int) {
Gosched() Gosched()
} }
lock(&sweep.lock) lock(&sweep.lock)
if !gosweepdone() { if !isSweepDone() {
// This can happen if a GC runs between // This can happen if a GC runs between
// gosweepone returning ^0 above // gosweepone returning ^0 above
// and the lock being acquired. // and the lock being acquired.
...@@ -134,8 +134,13 @@ func sweepone() uintptr { ...@@ -134,8 +134,13 @@ func sweepone() uintptr {
return npages return npages
} }
//go:nowritebarrier // isSweepDone reports whether all spans are swept or currently being swept.
func gosweepdone() bool { //
// Note that this condition may transition from false to true at any
// time as the sweeper runs. It may transition from true to false if a
// GC runs; to prevent that the caller must be non-preemptible or must
// somehow block GC progress.
func isSweepDone() bool {
return mheap_.sweepdone != 0 return mheap_.sweepdone != 0
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment