@@ -248,7 +248,7 @@ func (s *StoreInfo) LeaderScore(policy SchedulePolicy, delta int64) float64 {
248248func (s * StoreInfo ) RegionScore (version string , highSpaceRatio , lowSpaceRatio float64 , delta int64 , deviation int ) float64 {
249249 switch version {
250250 case "v2" :
251- return s .regionScoreV2 (delta , deviation )
251+ return s .regionScoreV2 (delta , deviation , lowSpaceRatio )
252252 case "v1" :
253253 fallthrough
254254 default :
@@ -301,15 +301,16 @@ func (s *StoreInfo) regionScoreV1(highSpaceRatio, lowSpaceRatio float64, delta i
301301 return score / math .Max (s .GetRegionWeight (), minWeight )
302302}
303303
304- func (s * StoreInfo ) regionScoreV2 (delta int64 , deviation int ) float64 {
304+ func (s * StoreInfo ) regionScoreV2 (delta int64 , deviation int , lowSpaceRatio float64 ) float64 {
305305 A := float64 (float64 (s .GetAvgAvailable ())- float64 (deviation )* float64 (s .GetAvailableDeviation ())) / gb
306306 C := float64 (s .GetCapacity ()) / gb
307307 R := float64 (s .GetRegionSize () + delta )
308308 var (
309309 K , M float64 = 1 , 256 // Experience value to control the weight of the available influence on score
310- F float64 = 20 // Experience value to prevent some nodes from running out of disk space prematurely.
310+ F float64 = 50 // Experience value to prevent some nodes from running out of disk space prematurely.
311+ B = 1e7
311312 )
312-
313+ F = math . Max ( F , C * ( 1 - lowSpaceRatio ))
313314 var score float64
314315 if A >= C || C < 1 {
315316 score = R
@@ -319,7 +320,8 @@ func (s *StoreInfo) regionScoreV2(delta int64, deviation int) float64 {
319320 score = (K + M * (math .Log (C )- math .Log (A - F + 1 ))/ (C - A + F - 1 )) * R
320321 } else {
321322 // When remaining space is less then F, the score is mainly determined by available space.
322- score = (K + M * math .Log (C )/ C )* R + (F - A )* (K + M * math .Log (F )/ F )
323+ // store's score will increase rapidly after it has few space. and it will reach similar score when they has no space
324+ score = (K + M * math .Log (C )/ C )* R + B * (F - A )/ F
323325 }
324326 return score / math .Max (s .GetRegionWeight (), minWeight )
325327}
0 commit comments