From b56b74cd2bf8f88f31efdaee319b4380f49a6263 Mon Sep 17 00:00:00 2001 From: bufferflies <1045931706@qq.com> Date: Fri, 22 Apr 2022 17:48:54 +0800 Subject: [PATCH] improve b Signed-off-by: bufferflies <1045931706@qq.com> --- server/core/store.go | 2 +- server/core/store_test.go | 8 ++++++-- server/core/test_util.go | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/server/core/store.go b/server/core/store.go index d58d09235aa..16c508d55ff 100644 --- a/server/core/store.go +++ b/server/core/store.go @@ -359,7 +359,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 diff --git a/server/core/store_test.go b/server/core/store_test.go index 700be818e7b..2bed3783f9e 100644 --- a/server/core/store_test.go +++ b/server/core/store_test.go @@ -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) @@ -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) diff --git a/server/core/test_util.go b/server/core/test_util.go index fb39a74dfe7..78e3c10508c 100644 --- a/server/core/test_util.go +++ b/server/core/test_util.go @@ -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