Stats on steals
This commit is contained in:
parent
6a23f311e1
commit
cdbd91b13b
6 changed files with 29 additions and 5 deletions
|
|
@ -113,7 +113,20 @@ impl PeerStates {
|
|||
Some(prev)
|
||||
}
|
||||
|
||||
pub(crate) fn send_cancellations(&self, from_peer: SocketAddr, stolen_idx: ValidPieceIndex) {
|
||||
pub(crate) fn on_steal(
|
||||
&self,
|
||||
from_peer: SocketAddr,
|
||||
to_peer: SocketAddr,
|
||||
stolen_idx: ValidPieceIndex,
|
||||
) {
|
||||
self.with_peer(to_peer, |p| {
|
||||
atomic_inc(&p.stats.counters.times_i_stole);
|
||||
});
|
||||
self.with_peer(from_peer, |p| {
|
||||
atomic_inc(&p.stats.counters.times_stolen_from_me);
|
||||
});
|
||||
self.stats.inc_steals();
|
||||
|
||||
self.with_live_mut(from_peer, "send_cancellations", |live| {
|
||||
let to_remove = live
|
||||
.inflight_requests
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ pub(crate) struct AggregatePeerStatsAtomic {
|
|||
pub seen: AtomicU32,
|
||||
pub dead: AtomicU32,
|
||||
pub not_needed: AtomicU32,
|
||||
pub steals: AtomicU32,
|
||||
}
|
||||
|
||||
impl AggregatePeerStatsAtomic {
|
||||
|
|
@ -40,4 +41,8 @@ impl AggregatePeerStatsAtomic {
|
|||
self.dec(old);
|
||||
self.inc(new);
|
||||
}
|
||||
|
||||
pub fn inc_steals(&self) {
|
||||
atomic_inc(&self.steals);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ pub struct AggregatePeerStats {
|
|||
pub seen: usize,
|
||||
pub dead: usize,
|
||||
pub not_needed: usize,
|
||||
pub steals: usize,
|
||||
}
|
||||
|
||||
impl<'a> From<&'a AggregatePeerStatsAtomic> for AggregatePeerStats {
|
||||
|
|
@ -24,6 +25,7 @@ impl<'a> From<&'a AggregatePeerStatsAtomic> for AggregatePeerStats {
|
|||
seen: s.seen.load(ordering) as usize,
|
||||
dead: s.dead.load(ordering) as usize,
|
||||
not_needed: s.not_needed.load(ordering) as usize,
|
||||
steals: s.steals.load(ordering) as usize,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue