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

release-23.1: kvserver,storepool: misc rebalance logging improvements #102951

Merged
merged 2 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/allocator/storepool/store_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ func MakeStoreList(descriptors []roachpb.StoreDescriptor) StoreList {
func (sl StoreList) String() string {
var buf bytes.Buffer
fmt.Fprintf(&buf,
" candidate: avg-ranges=%v avg-leases=%v avg-disk-usage=%v avg-queries-per-second=%v avg-store-cpu-per-second=%v",
" candidate: avg-ranges=%.2f avg-leases=%.2f avg-disk-usage=%s avg-queries-per-second=%.2f avg-store-cpu-per-second=%s",
sl.CandidateRanges.Mean,
sl.CandidateLeases.Mean,
humanizeutil.IBytes(int64(sl.candidateLogicalBytes.Mean)),
Expand Down
16 changes: 12 additions & 4 deletions pkg/kv/kvserver/rebalance_objective.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ const (
LBRebalancingCPU
)

// LoadBasedRebalancingObjectiveMap maps the LoadBasedRebalancingObjective enum
// value to a string.
var LoadBasedRebalancingObjectiveMap map[int64]string = map[int64]string{
int64(LBRebalancingQueries): "qps",
int64(LBRebalancingCPU): "cpu",
}

func (lbro LBRebalancingObjective) String() string {
return LoadBasedRebalancingObjectiveMap[int64(lbro)]
}

// LoadBasedRebalancingObjective is a cluster setting that defines the load
// balancing objective of the cluster.
var LoadBasedRebalancingObjective = settings.RegisterEnumSetting(
Expand All @@ -101,10 +112,7 @@ var LoadBasedRebalancingObjective = settings.RegisterEnumSetting(
"the cluster will attempt to balance qps among stores, if set to "+
"`cpu` the cluster will attempt to balance cpu usage among stores",
"cpu",
map[int64]string{
int64(LBRebalancingQueries): "qps",
int64(LBRebalancingCPU): "cpu",
},
LoadBasedRebalancingObjectiveMap,
).WithPublic()

// ToDimension returns the equivalent allocator load dimension of a rebalancing
Expand Down
3 changes: 3 additions & 0 deletions pkg/kv/kvserver/store_rebalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ func (sr *StoreRebalancer) Start(ctx context.Context, stopper *stop.Stopper) {
continue
}
objective := sr.RebalanceObjective()
sr.AddLogTag("obj", objective)
ctx = sr.AnnotateCtx(ctx)

hottestRanges := sr.replicaRankings.TopLoad(objective.ToDimension())
options := sr.scorerOptions(ctx, objective.ToDimension())
rctx := sr.NewRebalanceContext(ctx, options, hottestRanges, mode)
Expand Down