Skip to content

Commit 67ff3db

Browse files
authored
Merge pull request containerd#9795 from catap/prevent-zero-timer
Prevent GC from schedule itself with 0 period.
2 parents 4c6d0ef + c876612 commit 67ff3db

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

plugins/gc/scheduler.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ func schedule(d time.Duration) (<-chan time.Time, *time.Time) {
234234
}
235235

236236
func (s *gcScheduler) run(ctx context.Context) {
237+
const minimumGCTime = float64(5 * time.Millisecond)
237238
var (
238239
schedC <-chan time.Time
239240

@@ -331,6 +332,11 @@ func (s *gcScheduler) run(ctx context.Context) {
331332
// runtime in between gc to reach the pause threshold.
332333
// Pause threshold is always 0.0 < threshold <= 0.5
333334
avg := float64(gcTimeSum) / float64(collections)
335+
// Enforce that avg is no less than minimumGCTime
336+
// to prevent immediate rescheduling
337+
if avg < minimumGCTime {
338+
avg = minimumGCTime
339+
}
334340
interval = time.Duration(avg/s.pauseThreshold - avg)
335341
}
336342

0 commit comments

Comments
 (0)