Skip to content

Commit 7ac0a8b

Browse files
committed
runtime: remove unused gcTriggerAlways
This was used during the implementation of concurrent runtime.GC() but now there's nothing that triggers GC unconditionally. Remove this trigger type and simplify (gcTrigger).test() accordingly. Change-Id: I17a893c2ed1f661b8146d7783d529f71735c9105 Reviewed-on: https://go-review.googlesource.com/c/go/+/66090 Run-TryBot: Austin Clements <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Reviewed-by: Rick Hudson <[email protected]>
1 parent 4b14280 commit 7ac0a8b

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

src/runtime/mgc.go

+3-14
Original file line numberDiff line numberDiff line change
@@ -1136,15 +1136,10 @@ type gcTrigger struct {
11361136
type gcTriggerKind int
11371137

11381138
const (
1139-
// gcTriggerAlways indicates that a cycle should be started
1140-
// unconditionally, even if GOGC is off or we're in a cycle
1141-
// right now. This cannot be consolidated with other cycles.
1142-
gcTriggerAlways gcTriggerKind = iota
1143-
11441139
// gcTriggerHeap indicates that a cycle should be started when
11451140
// the heap size reaches the trigger heap size computed by the
11461141
// controller.
1147-
gcTriggerHeap
1142+
gcTriggerHeap gcTriggerKind = iota
11481143

11491144
// gcTriggerTime indicates that a cycle should be started when
11501145
// it's been more than forcegcperiod nanoseconds since the
@@ -1161,13 +1156,7 @@ const (
11611156
// that the exit condition for the _GCoff phase has been met. The exit
11621157
// condition should be tested when allocating.
11631158
func (t gcTrigger) test() bool {
1164-
if !memstats.enablegc || panicking != 0 {
1165-
return false
1166-
}
1167-
if t.kind == gcTriggerAlways {
1168-
return true
1169-
}
1170-
if gcphase != _GCoff {
1159+
if !memstats.enablegc || panicking != 0 || gcphase != _GCoff {
11711160
return false
11721161
}
11731162
switch t.kind {
@@ -1233,7 +1222,7 @@ func gcStart(trigger gcTrigger) {
12331222
}
12341223

12351224
// For stats, check if this GC was forced by the user.
1236-
work.userForced = trigger.kind == gcTriggerAlways || trigger.kind == gcTriggerCycle
1225+
work.userForced = trigger.kind == gcTriggerCycle
12371226

12381227
// In gcstoptheworld debug mode, upgrade the mode accordingly.
12391228
// We do this after re-checking the transition condition so

0 commit comments

Comments
 (0)