Skip to content

Commit fb905bb

Browse files
committed
Cleaned up experimental flags some more.
1 parent a3d96f8 commit fb905bb

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

src/runtime/mgc.go

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -733,12 +733,10 @@ func gcStart(trigger gcTrigger) {
733733
mode = gcForceMode
734734
} else if debug.gcstoptheworld == 2 {
735735
mode = gcForceBlockMode
736-
} else if goexperiment.GoroutineLeakFinderGC {
737-
if work.goroutineLeakFinder.pending.Load() ||
738-
debug.gcgoroutineleaks > 0 {
739-
// Fully stop the world if running deadlock detection.
740-
mode = gcForceBlockMode
741-
}
736+
} else if work.goroutineLeakFinder.pending.Load() || debug.gcgoroutineleaks > 0 {
737+
// If goroutine leak detection has been enabled (via GODEBUG=gcgoroutineleaks=1),
738+
// or via profiling, fully stop the world.
739+
mode = gcForceBlockMode
742740
}
743741

744742
// Ok, we're doing it! Stop everybody else
@@ -1035,7 +1033,8 @@ top:
10351033
}
10361034
}
10371035
})
1038-
if restart {
1036+
switch {
1037+
case restart:
10391038
gcDebugMarkDone.restartedDueTo27993 = true
10401039

10411040
getg().m.preemptoff = ""
@@ -1049,25 +1048,22 @@ top:
10491048
})
10501049
semrelease(&worldsema)
10511050
goto top
1052-
} else if goexperiment.GoroutineLeakFinderGC {
1053-
// If we are detecting goroutine leaks, do so now.
1054-
if work.goroutineLeakFinder.enabled && !work.goroutineLeakFinder.done {
1055-
// Detect goroutine leaks. If the returned value is true, then
1056-
// detection was performed during this cycle. Otherwise, more mark work is needed,
1057-
// or live goroutines were found.
1058-
work.goroutineLeakFinder.done = findGoleaks()
1059-
1060-
getg().m.preemptoff = ""
1061-
systemstack(func() {
1062-
// Accumulate the time we were stopped before we had to start again.
1063-
work.cpuStats.accumulateGCPauseTime(nanotime()-stw.finishedStopping, work.maxprocs)
1051+
case work.goroutineLeakFinder.enabled && !work.goroutineLeakFinder.done:
1052+
// Detect goroutine leaks. If the returned value is true, then detection was
1053+
// performed during this cycle. Otherwise, more runnable goroutines were discovered,
1054+
// requiring additional mark work.
1055+
work.goroutineLeakFinder.done = findGoleaks()
10641056

1065-
now := startTheWorldWithSema(0, stw)
1066-
work.pauseNS += now - stw.startedStopping
1067-
})
1068-
semrelease(&worldsema)
1069-
goto top
1070-
}
1057+
getg().m.preemptoff = ""
1058+
systemstack(func() {
1059+
// Accumulate the time we were stopped before we had to start again.
1060+
work.cpuStats.accumulateGCPauseTime(nanotime()-stw.finishedStopping, work.maxprocs)
1061+
1062+
now := startTheWorldWithSema(0, stw)
1063+
work.pauseNS += now - stw.startedStopping
1064+
})
1065+
semrelease(&worldsema)
1066+
goto top
10711067
}
10721068

10731069
gcComputeStartingStackSize()

src/runtime/mgcmark.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,11 @@ func gcPrepareMarkRoots() {
153153
// there's nothing to scan, and any roots they create during
154154
// the concurrent phase will be caught by the write barrier.
155155
if work.goroutineLeakFinder.enabled {
156+
// goroutine leak finder GC --- only prepare runnable
157+
// goroutines for marking.
156158
work.stackRoots, work.nLiveStackRoots = allGsSnapshotSortedForGC()
157159
} else {
158-
// regular GC --- scan every go routine
160+
// regular GC --- scan every goroutine
159161
work.stackRoots = allGsSnapshot()
160162
work.nLiveStackRoots = len(work.stackRoots)
161163
}

0 commit comments

Comments
 (0)