]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: avoid span root marking entirely during mark termination
authorAustin Clements <austin@google.com>
Fri, 11 Mar 2016 18:54:55 +0000 (13:54 -0500)
committerAustin Clements <austin@google.com>
Tue, 26 Apr 2016 23:39:58 +0000 (23:39 +0000)
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/20666
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/mgcmark.go

index 3c6aec943b48efab2a6128f0479120782bbbfbc8..838419040723a2e6af633ee1f50eef64b815397b 100644 (file)
@@ -55,8 +55,19 @@ func gcMarkRootPrepare() {
                }
        }
 
-       // Compute number of span roots.
-       work.nSpanRoots = (len(work.spans) + rootBlockSpans - 1) / rootBlockSpans
+       if !work.markrootDone {
+               // 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
        // to be consistent about how many markroot jobs we create and
@@ -263,14 +274,8 @@ func markrootSpans(gcw *gcWork, shard int) {
        // TODO(austin): There are several ideas for making this more
        // 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 {
-               return
+               throw("markrootSpans during second markroot")
        }
 
        sg := mheap_.sweepgen