Commit efb0c554 authored by Austin Clements's avatar Austin Clements

runtime: avoid span root marking entirely during mark termination

Currently we enqueue span root mark jobs during both concurrent mark
and mark termination, but we make the job a no-op during mark
termination.

This is silly. Instead of queueing them up just to not do them, don't
queue them up in the first place.

Change-Id: Ie1d36de884abfb17dd0db6f0449a2b7c997affab
Reviewed-on: https://go-review.googlesource.com/20666Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent e8337491
...@@ -55,8 +55,19 @@ func gcMarkRootPrepare() { ...@@ -55,8 +55,19 @@ func gcMarkRootPrepare() {
} }
} }
// Compute number of span roots. if !work.markrootDone {
work.nSpanRoots = (len(work.spans) + rootBlockSpans - 1) / rootBlockSpans // On the first markroot, we need to scan span roots.
// In concurrent GC, this happens during concurrent
// mark and we depend on addfinalizer to ensure the
// above invariants for objects that get finalizers
// after concurrent mark. In STW GC, this will happen
// during mark termination.
work.nSpanRoots = (len(work.spans) + rootBlockSpans - 1) / rootBlockSpans
} else {
// We've already scanned span roots and kept the scan
// up-to-date during concurrent mark.
work.nSpanRoots = 0
}
// Snapshot of allglen. During concurrent scan, we just need // Snapshot of allglen. During concurrent scan, we just need
// to be consistent about how many markroot jobs we create and // to be consistent about how many markroot jobs we create and
...@@ -263,14 +274,8 @@ func markrootSpans(gcw *gcWork, shard int) { ...@@ -263,14 +274,8 @@ func markrootSpans(gcw *gcWork, shard int) {
// TODO(austin): There are several ideas for making this more // TODO(austin): There are several ideas for making this more
// efficient in issue #11485. // efficient in issue #11485.
// We process objects with finalizers only during the first
// markroot pass. In concurrent GC, this happens during
// concurrent mark and we depend on addfinalizer to ensure the
// above invariants for objects that get finalizers after
// concurrent mark. In STW GC, this will happen during mark
// termination.
if work.markrootDone { if work.markrootDone {
return throw("markrootSpans during second markroot")
} }
sg := mheap_.sweepgen sg := mheap_.sweepgen
......
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