Skip to content

Commit

Permalink
reduce NewStoreRecentlySplitFilter
Browse files Browse the repository at this point in the history
Signed-off-by: bufferflies <[email protected]>
  • Loading branch information
bufferflies committed Sep 19, 2023
1 parent f2a01b2 commit 159a375
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pkg/schedule/schedulers/balance_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ const (
// Default value is 4 which is subjected by scheduler-max-waiting-operator and leader-schedule-limit
// If you want to increase balance speed more, please increase above-mentioned param.
BalanceLeaderBatchSize = 4
// MaxBalanceLeaderBatchSize is maximum of balance leader batch size
MaxBalanceLeaderBatchSize = 10

transferIn = "transfer-in"
transferOut = "transfer-out"
Expand Down Expand Up @@ -150,7 +148,7 @@ func (handler *balanceLeaderHandler) UpdateConfig(w http.ResponseWriter, r *http
handler.rd.JSON(w, httpCode, v)
}

func (handler *balanceLeaderHandler) ListConfig(w http.ResponseWriter, r *http.Request) {
func (handler *balanceLeaderHandler) ListConfig(w http.ResponseWriter, _ *http.Request) {
conf := handler.config.Clone()
handler.rd.JSON(w, http.StatusOK, conf)
}
Expand All @@ -162,6 +160,7 @@ type balanceLeaderScheduler struct {
conf *balanceLeaderSchedulerConfig
handler http.Handler
filters []filter.Filter
regionFilters filter.RegionFilter
filterCounter *filter.Counter
}

Expand All @@ -184,6 +183,7 @@ func newBalanceLeaderScheduler(opController *operator.Controller, conf *balanceL
&filter.StoreStateFilter{ActionScope: s.GetName(), TransferLeader: true, ForbidRecentlySplitRegions: true, OperatorLevel: constant.High},
filter.NewSpecialUseFilter(s.GetName()),
}
s.regionFilters = filter.NewStoreRecentlySplitFilter(opController.GetCluster().GetStores())
return s
}

Expand Down Expand Up @@ -277,7 +277,7 @@ func (cs *candidateStores) less(iID uint64, scorei float64, jID uint64, scorej f
return scorei > scorej
}

// hasStore returns returns true when there are leftover stores.
// hasStore returns true when there are leftover stores.
func (cs *candidateStores) hasStore() bool {
return cs.index < len(cs.stores)
}
Expand Down Expand Up @@ -486,8 +486,7 @@ func (l *balanceLeaderScheduler) transferLeaderOut(solver *solver, collector *pl
// the worst follower peer and transfers the leader.
func (l *balanceLeaderScheduler) transferLeaderIn(solver *solver, collector *plan.Collector) *operator.Operator {
solver.Region = filter.SelectOneRegion(solver.RandFollowerRegions(solver.TargetStoreID(), l.conf.Ranges),
nil, filter.NewRegionPendingFilter(), filter.NewRegionDownFilter(),
filter.NewStoreRecentlySplitFilter(solver.GetStores()))
nil, filter.NewRegionPendingFilter(), filter.NewRegionDownFilter(), l.regionFilters)
if solver.Region == nil {
log.Debug("store has no follower", zap.String("scheduler", l.GetName()), zap.Uint64("store-id", solver.TargetStoreID()))
balanceLeaderNoFollowerRegionCounter.Inc()
Expand Down

0 comments on commit 159a375

Please sign in to comment.