Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scheduler: refine the interval of scheduling tick in evict-slow-trend-scheduler. #7326

Merged
merged 9 commits into from
Nov 10, 2023
19 changes: 18 additions & 1 deletion pkg/schedule/schedulers/evict_slow_trend.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ func (conf *evictSlowTrendSchedulerConfig) getKeyRangesByID(id uint64) []core.Ke
return []core.KeyRange{core.NewKeyRange("", "")}
}

func (conf *evictSlowTrendSchedulerConfig) hasEvictedStores() bool {
return len(conf.EvictedStores) > 0
}

func (conf *evictSlowTrendSchedulerConfig) evictedStore() uint64 {
if len(conf.EvictedStores) == 0 {
if !conf.hasEvictedStores() {
return 0
}
// If a candidate passes all checks and proved to be slow, it will be
Expand Down Expand Up @@ -237,6 +241,19 @@ type evictSlowTrendScheduler struct {
handler http.Handler
}

func (s *evictSlowTrendScheduler) GetNextInterval(interval time.Duration) time.Duration {
var growthType intervalGrowthType
// If it already found a slow node as candidate, the next interval should be shorter
// to make the next scheduling as soon as possible. This adjustment will decrease the
// response time, as heartbeats from other nodes will be received and updated more quickly.
if s.conf.hasEvictedStores() {
growthType = zeroGrowth
} else {
growthType = exponentialGrowth
}
return intervalGrow(s.GetMinInterval(), MaxScheduleInterval, growthType)
}

func (s *evictSlowTrendScheduler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s.handler.ServeHTTP(w, r)
}
Expand Down
Loading