-
Notifications
You must be signed in to change notification settings - Fork 726
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
statistic: collect both read and write pending influence at the same time #5521
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -366,13 +366,19 @@ func (f *hotPeerCache) isRegionHotWithPeer(region *core.RegionInfo, peer *metapb | |
if peer == nil { | ||
return false | ||
} | ||
storeID := peer.GetStoreId() | ||
if stat := f.getHotPeerStat(region.GetID(), peer.GetStoreId()); stat != nil { | ||
return stat.HotDegree >= hotDegree | ||
} | ||
return false | ||
} | ||
|
||
func (f *hotPeerCache) getHotPeerStat(regionID, storeID uint64) *HotPeerStat { | ||
if peers, ok := f.peersOfStore[storeID]; ok { | ||
if stat := peers.Get(region.GetID()); stat != nil { | ||
return stat.(*HotPeerStat).HotDegree >= hotDegree | ||
if stat := peers.Get(regionID); stat != nil { | ||
return stat.(*HotPeerStat) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there times when there may be insufficient statistical confidence? |
||
} | ||
} | ||
return false | ||
return nil | ||
} | ||
|
||
func (f *hotPeerCache) updateHotPeerStat(region *core.RegionInfo, newItem, oldItem *HotPeerStat, deltaLoads []float64, interval time.Duration) *HotPeerStat { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,6 +154,17 @@ func (rw RWType) RegionStats() []RegionStatKind { | |
return nil | ||
} | ||
|
||
// Inverse returns the opposite of kind. | ||
func (rw RWType) Inverse() RWType { | ||
switch rw { | ||
case Write: | ||
return Read | ||
case Read: | ||
return Write | ||
} | ||
return Read | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why default read? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. == There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there are only two kind in RWType There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can panic if not match |
||
} | ||
|
||
// GetLoadRatesFromPeer gets the load rates of the read or write type from PeerInfo. | ||
func (rw RWType) GetLoadRatesFromPeer(peer *core.PeerInfo) []float64 { | ||
deltaLoads := peer.GetLoads() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer summary all loads at a same time (including read and write) in
prepareForBalance
, then get it from thestLoadInfos
. it is at a same "snapshot" rather than get it one by one.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we don't need to use read and write statistics together. I think we can do this when we unify read and write schedulers later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it will be placed into together when we unify read and write schedulers.