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

core: change scoreV2 to adapt the higher disk capacity and amp . #4837

Merged
merged 1 commit into from
Apr 24, 2022
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 server/core/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ func (s *StoreInfo) regionScoreV2(delta int64, lowSpaceRatio float64) float64 {
var (
K, M float64 = 1, 256 // Experience value to control the weight of the available influence on score
F float64 = 50 // Experience value to prevent some nodes from running out of disk space prematurely.
B = 1e7
B = 1e10
)
F = math.Max(F, C*(1-lowSpaceRatio))
var score float64
Expand Down
8 changes: 6 additions & 2 deletions server/core/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ func (s *testStoreSuite) TestLowSpaceScoreV2(c *C) {
small: NewStoreInfoWithAvailable(2, 10*gb, 100*gb, 1.4),
}, {
// store1 and store2 has same available ratio less than 0.2
bigger: NewStoreInfoWithAvailable(1, 10*gb, 1000*gb, 1.4),
small: NewStoreInfoWithAvailable(2, 1*gb, 100*gb, 1.4),
bigger: NewStoreInfoWithAvailable(1, 20*gb, 1000*gb, 1.4),
small: NewStoreInfoWithAvailable(2, 10*gb, 500*gb, 1.4),
}, {
// store1 and store2 has same available ratio
// but the store1 ratio less than store2 ((50-10)/50=0.8<(200-100)/200=0.5)
Expand All @@ -164,6 +164,10 @@ func (s *testStoreSuite) TestLowSpaceScoreV2(c *C) {
// but store1 has higher amp, so store1(60g) has more regionSize (40g)
bigger: NewStoreInfoWithAvailable(1, 80*gb, 100*gb, 3),
small: NewStoreInfoWithAvailable(2, 60*gb, 100*gb, 1),
}, {
// store1's capacity is less than store2's capacity, but store2 has more available space,
bigger: NewStoreInfoWithAvailable(1, 2*gb, 100*gb, 3),
small: NewStoreInfoWithAvailable(2, 100*gb, 10*1000*gb, 3),
}}
for _, v := range testdata {
score1 := v.bigger.regionScoreV2(0, 0.8)
Expand Down
2 changes: 1 addition & 1 deletion server/core/test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func NewTestRegionInfo(start, end []byte) *RegionInfo {
}}
}

// NewStoreInfoWithAvailable is create with available and capacity
// NewStoreInfoWithAvailable is created with available and capacity
func NewStoreInfoWithAvailable(id, available, capacity uint64, amp float64) *StoreInfo {
stats := &pdpb.StoreStats{}
stats.Capacity = capacity
Expand Down