mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: track the number of active sweepone calls
sweepone returns ^uintptr(0) when there are no more spans to *start* sweeping, but there may be spans being swept concurrently at the time and there's currently no efficient way to tell when the sweeper is done sweeping all the spans. We'll need this for concurrent runtime.GC(), so add a count of the number of active sweepone calls to make it possible to block until sweeping is truly done. This is also useful for more accurately printing the gcpacertrace, since that should be printed after all of the sweeping stats are in (currently we can print it slightly too early). For #18216. Change-Id: I06e6240c9e7b40aca6fd7b788bb6962107c10a0f Reviewed-on: https://go-review.googlesource.com/37716 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org>
This commit is contained in:
parent
2919132e1b
commit
44ed88a5a7
2 changed files with 23 additions and 14 deletions
|
|
@ -35,6 +35,7 @@ type mheap struct {
|
|||
busylarge mSpanList // busy lists of large spans length >= _MaxMHeapList
|
||||
sweepgen uint32 // sweep generation, see comment in mspan
|
||||
sweepdone uint32 // all spans are swept
|
||||
sweepers uint32 // number of active sweepone calls
|
||||
|
||||
// allspans is a slice of all mspans ever created. Each mspan
|
||||
// appears exactly once.
|
||||
|
|
@ -71,7 +72,7 @@ type mheap struct {
|
|||
// on the swept stack.
|
||||
sweepSpans [2]gcSweepBuf
|
||||
|
||||
// _ uint32 // align uint64 fields on 32-bit for atomics
|
||||
_ uint32 // align uint64 fields on 32-bit for atomics
|
||||
|
||||
// Proportional sweep
|
||||
pagesInUse uint64 // pages of spans in stats _MSpanInUse; R/W with mheap.lock
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue