Skip to content

Commit

Permalink
scheduler: refine the interval of scheduling tick in evict-slow-trend…
Browse files Browse the repository at this point in the history
…-scheduler. (#7326)

ref #7156

Implement the `GetNextInterval` for `evict-slow-trend-scheduler`, to refine the ticking interval.

Default `GetNextInterval` is not appropriate for `evict-slow-trend-scheduler`, as it might delay
the checking of other nodes' slowness status.

This pr adjusts the ticking interval of the evict-slow-trend-scheduler to optimize
its behavior. If a slow node is already identified as a candidate, the next
interval is now set to be shorter, ensuring quicker subsequent scheduling. 
This refinement aims to decrease response time.

Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
LykxSassinator and ti-chi-bot[bot] authored Nov 10, 2023
1 parent f1cee6c commit b5119ea
Showing 1 changed file with 18 additions and 1 deletion.
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

0 comments on commit b5119ea

Please sign in to comment.