diff --git a/plugins/gc/scheduler.go b/plugins/gc/scheduler.go index 3213ba3dd..ff78edee1 100644 --- a/plugins/gc/scheduler.go +++ b/plugins/gc/scheduler.go @@ -234,6 +234,7 @@ func schedule(d time.Duration) (<-chan time.Time, *time.Time) { } func (s *gcScheduler) run(ctx context.Context) { + const minimumGCTime = float64(5 * time.Millisecond) var ( schedC <-chan time.Time @@ -331,6 +332,11 @@ func (s *gcScheduler) run(ctx context.Context) { // runtime in between gc to reach the pause threshold. // Pause threshold is always 0.0 < threshold <= 0.5 avg := float64(gcTimeSum) / float64(collections) + // Enforce that avg is no less than minimumGCTime + // to prevent immediate rescheduling + if avg < minimumGCTime { + avg = minimumGCTime + } interval = time.Duration(avg/s.pauseThreshold - avg) }