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

kvserver: increase rebalance action impact req #98889

Merged
merged 1 commit into from
Jun 7, 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
17 changes: 13 additions & 4 deletions pkg/kv/kvserver/store_rebalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ const (
RebalanceTargetFound
)

const (
// minLeaseLoadFraction is the minimum fraction of the local store's load a
// lease must contribute, in order to consider it worthwhile rebalancing when
// overfull.
minLeaseLoadFraction = 0.005
// minReplicaLoadFraction is the minimum fraction of the local store's load a
// replica (lease included) must contribute, in order to consider it
// worthwhile rebalancing when overfull.
minReplicaLoadFraction = 0.02
)

// StoreRebalancer is responsible for examining how the associated store's load
// compares to the load on other stores in the cluster and transferring leases
// or replicas away if the local store is overloaded.
Expand Down Expand Up @@ -716,9 +727,8 @@ func (sr *StoreRebalancer) chooseLeaseToTransfer(
// Don't bother moving leases whose load is below some small fraction of the
// store's load. It's just unnecessary churn with no benefit to move leases
// responsible for, for example, 1 load unit on a store with 5000 load units.
const minLoadFraction = .001
if candidateReplica.RangeUsageInfo().TransferImpact().Dim(rctx.loadDimension) <
rctx.LocalDesc.Capacity.Load().Dim(rctx.loadDimension)*minLoadFraction {
rctx.LocalDesc.Capacity.Load().Dim(rctx.loadDimension)*minLeaseLoadFraction {
log.KvDistribution.VEventf(ctx, 3, "r%d's %s load is too little to matter relative to s%d's %s total load",
candidateReplica.GetRangeID(), candidateReplica.RangeUsageInfo().TransferImpact(),
rctx.LocalDesc.StoreID, rctx.LocalDesc.Capacity.Load())
Expand Down Expand Up @@ -838,9 +848,8 @@ func (sr *StoreRebalancer) chooseRangeToRebalance(
// Don't bother moving ranges whose load is below some small fraction of the
// store's load. It's just unnecessary churn with no benefit to move ranges
// responsible for, for example, 1 load unit on a store with 5000 load units.
const minLoadFraction = .001
if candidateReplica.RangeUsageInfo().Load().Dim(rctx.loadDimension) <
rctx.LocalDesc.Capacity.Load().Dim(rctx.loadDimension)*minLoadFraction {
rctx.LocalDesc.Capacity.Load().Dim(rctx.loadDimension)*minReplicaLoadFraction {
log.KvDistribution.VEventf(
ctx,
5,
Expand Down
18 changes: 10 additions & 8 deletions pkg/kv/kvserver/store_rebalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -746,28 +746,30 @@ func TestChooseLeaseToTransfer(t *testing.T) {
expectTarget: 5,
},

// NB: The lease has just enough load to be worthwhile rebalancing.
{
storeIDs: []roachpb.StoreID{1, 4},
qps: 1.5,
reqCPU: 1.5 * float64(time.Millisecond),
qps: minLeaseLoadFraction * localDesc.Capacity.QueriesPerSecond,
reqCPU: minLeaseLoadFraction * localDesc.Capacity.CPUPerSecond,
expectTarget: 4,
},
{
storeIDs: []roachpb.StoreID{1, 5},
qps: 1.5,
reqCPU: 1.5 * float64(time.Millisecond),
qps: minLeaseLoadFraction * localDesc.Capacity.QueriesPerSecond,
reqCPU: minLeaseLoadFraction * localDesc.Capacity.CPUPerSecond,
expectTarget: 5,
},
// NB: The lease is no longer worth rebalancing.
{
storeIDs: []roachpb.StoreID{1, 4},
qps: 1.49,
reqCPU: 1.49 * float64(time.Millisecond),
qps: minLeaseLoadFraction*localDesc.Capacity.QueriesPerSecond - 1,
reqCPU: minLeaseLoadFraction*localDesc.Capacity.CPUPerSecond - 1,
expectTarget: 0,
},
{
storeIDs: []roachpb.StoreID{1, 5},
qps: 1.49,
reqCPU: 1.49 * float64(time.Millisecond),
qps: minLeaseLoadFraction*localDesc.Capacity.QueriesPerSecond - 1,
reqCPU: minLeaseLoadFraction*localDesc.Capacity.CPUPerSecond - 1,
expectTarget: 0,
},
{
Expand Down