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

schedulers: speed up the balance-region-scheduler by decrease influence amp. (#5254) #5320

Merged
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
1 change: 1 addition & 0 deletions server/grpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ func (s *GrpcServer) RegionHeartbeat(stream pdpb.PD_RegionHeartbeatServer) error

for {
request, err := server.Recv()
regionHeartbeatCounter.WithLabelValues("fake", "fake", "report", "pending").Inc()
if err == io.EOF {
return nil
}
Expand Down
34 changes: 33 additions & 1 deletion server/schedulers/balance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,38 @@ type testBalanceSpeedCase struct {
kind core.SchedulePolicy
}

func (s *testBalanceSuite) TestInfluenceAmp(c *C) {
R := int64(96)
opt := config.NewTestOptions()
tc := mockcluster.NewCluster(s.ctx, opt)
kind := core.NewScheduleKind(core.RegionKind, core.BySize)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
oc := schedule.NewOperatorController(ctx, nil, nil)
influence := oc.GetOpInfluence(tc)
influence.GetStoreInfluence(1).RegionSize = R
influence.GetStoreInfluence(2).RegionSize = -R
tc.SetTolerantSizeRatio(1)

// It will schedule if the diff region count is greater than the sum
// of TolerantSizeRatio and influenceAmp*2.
tc.AddRegionStore(1, int(100+influenceAmp+3))
tc.AddRegionStore(2, int(100-influenceAmp))
tc.AddLeaderRegion(1, 1, 2)
region := tc.GetRegion(1).Clone(core.SetApproximateSize(R))
tc.PutRegion(region)
plan := newBalancePlan(kind, tc, influence)
plan.source, plan.target, plan.region = tc.GetStore(1), tc.GetStore(2), tc.GetRegion(1)
c.Assert(plan.shouldBalance(""), IsTrue)

// It will not schedule if the diff region count is greater than the sum
// of TolerantSizeRatio and influenceAmp*2.
tc.AddRegionStore(1, int(100+influenceAmp+2))
plan.source = tc.GetStore(1)
c.Assert(plan.shouldBalance(""), IsFalse)
c.Assert(plan.sourceScore-plan.targetScore, Less, float64(1))
}

func (s *testBalanceSuite) TestShouldBalance(c *C) {
// store size = 100GiB
// region size = 96MiB
Expand Down Expand Up @@ -989,7 +1021,7 @@ func (s *testBalanceRegionSchedulerSuite) TestOpInfluence(c *C) {
c.Assert(op, NotNil)
oc.AddOperator(op)
}
testutil.CheckTransferPeerWithLeaderTransfer(c, sb.Schedule(tc)[0], operator.OpKind(0), 3, 1)
testutil.CheckTransferPeerWithLeaderTransfer(c, sb.Schedule(tc)[0], operator.OpKind(0), 2, 1)
}

func (s *testBalanceRegionSchedulerSuite) checkReplacePendingRegion(c *C, tc *mockcluster.Cluster, sb schedule.Scheduler) {
Expand Down
2 changes: 1 addition & 1 deletion server/schedulers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (
adjustRatio float64 = 0.005
leaderTolerantSizeRatio float64 = 5.0
minTolerantSizeRatio float64 = 1.0
influenceAmp int64 = 100
influenceAmp int64 = 5
defaultMinRetryLimit = 1
defaultRetryQuotaAttenuation = 2
)
Expand Down