Skip to content

Commit

Permalink
Stats for overflow wakers (seems that there are duplicates)
Browse files Browse the repository at this point in the history
  • Loading branch information
akoshelev committed Nov 23, 2023
1 parent ec1466e commit c114f39
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/helpers/buffers/unordered_receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,22 @@ where
if self.next % (self.wakers.len() / 2) == 0 {
// Wake all the overflowed wakers. See comments on `overflow_wakers`.
#[cfg(feature = "stall-detection")]
{
use std::collections::HashMap;

let vec = take(&mut self.overflow_wakers);
let sz = vec.len();
let mut idx_stats = HashMap::new();
for (w, i) in vec {
idx_stats.entry(i).and_modify(|v| *v += 1).or_insert(1);
w.wake();
}

let mut idx_stats = idx_stats.into_iter().collect::<Vec<_>>();
idx_stats.sort_unstable_by_key(|(_, v)| std::cmp::Reverse(*v));
let worst = idx_stats.first().map(|(idx, st)| format!("{idx}={st}")).unwrap_or("<>".to_string());
tracing::info!("overflow waker stats: {} total size, {} total indices, {} max wakers per index", sz, idx_stats.len(), worst);
}
for (w, _) in take(&mut self.overflow_wakers) {
w.wake();
}
Expand Down

0 comments on commit c114f39

Please sign in to comment.