Skip to content

Commit

Permalink
statistics: reduce the call times of DefaultAntiCount (#5760)
Browse files Browse the repository at this point in the history
ref #5692

Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx authored Dec 6, 2022
1 parent 54f2a32 commit b072008
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/statistics/hot_peer_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,12 @@ func NewHotPeerCache(kind RWType) *hotPeerCache {
// RegionStats returns hot items
func (f *hotPeerCache) RegionStats(minHotDegree int) map[uint64][]*HotPeerStat {
res := make(map[uint64][]*HotPeerStat)
defaultAntiCount := f.kind.DefaultAntiCount()
for storeID, peers := range f.peersOfStore {
values := peers.GetAll()
stat := make([]*HotPeerStat, 0, len(values))
for _, v := range values {
if peer := v.(*HotPeerStat); peer.HotDegree >= minHotDegree && !peer.inCold && peer.AntiCount == f.kind.DefaultAntiCount() {
if peer := v.(*HotPeerStat); peer.HotDegree >= minHotDegree && !peer.inCold && peer.AntiCount == defaultAntiCount {
stat = append(stat, peer)
}
}
Expand Down

0 comments on commit b072008

Please sign in to comment.