diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 7fdd93b6008..848e8f69927 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -126,13 +126,14 @@ const ( _DebugGC = 0 _ConcurrentSweep = true _FinBlockSize = 4 * 1024 + _RootData = 0 _RootBss = 1 _RootFinalizers = 2 - _RootSpans0 = 3 + _RootFlushCaches = 3 + _RootSpans0 = 4 _RootSpansShards = 128 - _RootFlushCaches = _RootSpans0 + _RootSpansShards - _RootCount = _RootFlushCaches + 1 + _RootCount = _RootSpans0 + _RootSpansShards // sweepMinHeapDistance is a lower bound on the heap distance // (in bytes) reserved for concurrent sweeping between GC diff --git a/src/runtime/mgcmark.go b/src/runtime/mgcmark.go index 128a163297f..c8f8a66b458 100644 --- a/src/runtime/mgcmark.go +++ b/src/runtime/mgcmark.go @@ -121,8 +121,7 @@ func markrootSpans(gcw *gcWork, shard int) { sg := mheap_.sweepgen startSpan := shard * len(work.spans) / _RootSpansShards endSpan := (shard + 1) * len(work.spans) / _RootSpansShards - for spanidx := startSpan; spanidx < endSpan; spanidx++ { - s := work.spans[spanidx] + for _, s := range work.spans[startSpan:endSpan] { if s.state != mSpanInUse { continue }