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: avoid to updateCounts frequently #7836

Merged
merged 5 commits into from
Feb 29, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/schedule/operator/operator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ func (oc *Controller) addOperatorLocked(op *Operator) bool {
return false
}
oc.operators[regionID] = op
oc.counts[op.SchedulerKind()]++
operatorCounter.WithLabelValues(op.Desc(), "start").Inc()
operatorSizeHist.WithLabelValues(op.Desc()).Observe(float64(op.ApproximateSize))
opInfluence := NewTotalOpInfluence([]*Operator{op}, oc.cluster)
Expand All @@ -505,7 +506,6 @@ func (oc *Controller) addOperatorLocked(op *Operator) bool {
storeLimitCostCounter.WithLabelValues(strconv.FormatUint(storeID, 10), n).Add(float64(stepCost) / float64(storelimit.RegionInfluence[v]))
}
}
oc.updateCounts(oc.operators)

var step OpStep
if region := oc.cluster.GetRegion(op.RegionID()); region != nil {
Expand Down Expand Up @@ -602,7 +602,7 @@ func (oc *Controller) removeOperatorLocked(op *Operator) bool {
regionID := op.RegionID()
if cur := oc.operators[regionID]; cur == op {
delete(oc.operators, regionID)
oc.updateCounts(oc.operators)
oc.counts[op.SchedulerKind()]--
HuSharp marked this conversation as resolved.
Show resolved Hide resolved
operatorCounter.WithLabelValues(op.Desc(), "remove").Inc()
oc.ack(op)
if op.Kind()&OpMerge != 0 {
Expand Down Expand Up @@ -862,7 +862,7 @@ func (oc *Controller) SetOperator(op *Operator) {
oc.Lock()
defer oc.Unlock()
oc.operators[op.RegionID()] = op
oc.updateCounts(oc.operators)
oc.counts[op.SchedulerKind()]++
}

// OpWithStatus records the operator and its status.
Expand Down
Loading