mirror of
https://github.com/containerd/containerd.git
synced 2026-11-06 21:37:23 +00:00
Merge pull request #10102 from catap/prevent-zero-timer-1.7
[release/1.7] Prevent GC from schedule itself with 0 period.
This commit is contained in:
1 file changed
+6
@@ -246,6 +246,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
|
||||
|
||||
@@ -343,6 +344,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)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user