|
@@ -4,6 +4,7 @@ use {
|
|
|
solana_measure::measure::Measure,
|
|
solana_measure::measure::Measure,
|
|
|
solana_sdk::{clock::Slot, pubkey::Pubkey},
|
|
solana_sdk::{clock::Slot, pubkey::Pubkey},
|
|
|
std::{
|
|
std::{
|
|
|
|
|
+ cmp::Reverse,
|
|
|
collections::HashMap,
|
|
collections::HashMap,
|
|
|
ops::{Deref, DerefMut},
|
|
ops::{Deref, DerefMut},
|
|
|
sync::atomic::{AtomicU64, Ordering},
|
|
sync::atomic::{AtomicU64, Ordering},
|
|
@@ -564,20 +565,8 @@ pub(crate) fn submit_gossip_stats(
|
|
|
("all-push", crds_stats.push.fails.iter().sum::<usize>(), i64),
|
|
("all-push", crds_stats.push.fails.iter().sum::<usize>(), i64),
|
|
|
("all-pull", crds_stats.pull.fails.iter().sum::<usize>(), i64),
|
|
("all-pull", crds_stats.pull.fails.iter().sum::<usize>(), i64),
|
|
|
);
|
|
);
|
|
|
- for (slot, num_votes) in &crds_stats.pull.votes {
|
|
|
|
|
- datapoint_info!(
|
|
|
|
|
- "cluster_info_crds_stats_votes_pull",
|
|
|
|
|
- ("slot", *slot, i64),
|
|
|
|
|
- ("num_votes", *num_votes, i64),
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
- for (slot, num_votes) in &crds_stats.push.votes {
|
|
|
|
|
- datapoint_info!(
|
|
|
|
|
- "cluster_info_crds_stats_votes_push",
|
|
|
|
|
- ("slot", *slot, i64),
|
|
|
|
|
- ("num_votes", *num_votes, i64),
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ submit_vote_stats("cluster_info_crds_stats_votes_pull", &crds_stats.pull.votes);
|
|
|
|
|
+ submit_vote_stats("cluster_info_crds_stats_votes_push", &crds_stats.push.votes);
|
|
|
let votes: HashMap<Slot, usize> = crds_stats
|
|
let votes: HashMap<Slot, usize> = crds_stats
|
|
|
.pull
|
|
.pull
|
|
|
.votes
|
|
.votes
|
|
@@ -592,11 +581,20 @@ pub(crate) fn submit_gossip_stats(
|
|
|
)
|
|
)
|
|
|
.into_grouping_map()
|
|
.into_grouping_map()
|
|
|
.aggregate(|acc, _slot, num_votes| Some(acc.unwrap_or_default() + num_votes));
|
|
.aggregate(|acc, _slot, num_votes| Some(acc.unwrap_or_default() + num_votes));
|
|
|
- for (slot, num_votes) in votes {
|
|
|
|
|
- datapoint_info!(
|
|
|
|
|
- "cluster_info_crds_stats_votes",
|
|
|
|
|
- ("slot", slot, i64),
|
|
|
|
|
- ("num_votes", num_votes, i64),
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ submit_vote_stats("cluster_info_crds_stats_votes", &votes);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+fn submit_vote_stats<'a, I>(name: &'static str, votes: I)
|
|
|
|
|
+where
|
|
|
|
|
+ I: IntoIterator<Item = (&'a Slot, /*num-votes:*/ &'a usize)>,
|
|
|
|
|
+{
|
|
|
|
|
+ // Submit vote stats only for the top most voted slots.
|
|
|
|
|
+ const NUM_SLOTS: usize = 20;
|
|
|
|
|
+ let mut votes: Vec<_> = votes.into_iter().map(|(k, v)| (*k, *v)).collect();
|
|
|
|
|
+ if votes.len() > NUM_SLOTS {
|
|
|
|
|
+ votes.select_nth_unstable_by_key(NUM_SLOTS, |(_, num)| Reverse(*num));
|
|
|
|
|
+ }
|
|
|
|
|
+ for (slot, num_votes) in votes.into_iter().take(NUM_SLOTS) {
|
|
|
|
|
+ datapoint_info!(name, ("slot", slot, i64), ("num_votes", num_votes, i64),);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|