Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
nolouch committed Apr 26, 2017
1 parent 79a39d8 commit 79b9de3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions server/balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ func (h *balanceHotRegionScheduler) calculateScore(cluster *clusterInfo) {
status, ok := h.scoreStatus[storeID]
if !ok {
status = &StoreHotRegions{
RegionsStat: make(RegionsStat, 0, 100),
RegionsStat: make(RegionsStat, 0, storeHotRegionsDefaultLen),
}
h.scoreStatus[storeID] = status
}
Expand Down Expand Up @@ -528,7 +528,7 @@ func (h *balanceHotRegionScheduler) SelectSourceRegion(cluster *clusterInfo) *Re
// the hottest region in the store not move
// randomly pick a region from 1 .. length-1
// TODO: consider hot degree when pick
rr := h.r.Int31n(int32(length-1)) + 1
rr := h.r.Intn(length-1) + 1
pickedRegionStat := h.scoreStatus[sourceStore].RegionsStat[rr]
if pickedRegionStat.antiCount < hotRegionAntiCount {
return nil
Expand All @@ -551,8 +551,8 @@ func (h *balanceHotRegionScheduler) adjustBalanceLimit(storeID uint64) {
}

avgRegionCount := hotRegionTotalCount / float64(len(h.scoreStatus))
// Multiplied by 0.75 to avoid transfer back and forth
limit := uint64((float64(s.RegionsStat.Len()) - avgRegionCount) * 0.75)
// Multiplied by hotRegionLimitCoeff to avoid transfer back and forth
limit := uint64((float64(s.RegionsStat.Len()) - avgRegionCount) * hotRegionLimitCoeff)
h.limit = maxUint64(1, limit)
}

Expand Down
2 changes: 2 additions & 0 deletions server/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const (
scheduleIntervalFactor = 1.3

writeStatLRUMaxLen = 1000
storeHotRegionsDefaultLen = 100
hotRegionLimitCoeff = 0.75

This comment has been minimized.

Copy link
@siddontang

siddontang Apr 27, 2017

Contributor

what does Coeff mean?

hotRegionScheduleFactor = 0.9
hotRegionMinWriteRate = 16 * 1024
regionHeartBeatReportInterval = 60
Expand Down

0 comments on commit 79b9de3

Please sign in to comment.