From 5162e9b6a3d1ed0e5268c305d5f6ab3c3672fc45 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 8 Aug 2024 19:06:19 +0000 Subject: [PATCH] add timer measuring time to populate gossip message vectors --- gossip/src/cluster_info.rs | 55 ++++++++++++++++-------------- gossip/src/cluster_info_metrics.rs | 6 ++++ 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/gossip/src/cluster_info.rs b/gossip/src/cluster_info.rs index 36ed72ddee6f43..de89048412d2de 100644 --- a/gossip/src/cluster_info.rs +++ b/gossip/src/cluster_info.rs @@ -2520,38 +2520,41 @@ impl ClusterInfo { let mut prune_messages = vec![]; let mut ping_messages = vec![]; let mut pong_messages = vec![]; - for (from_addr, packet) in packets { - match packet { - Protocol::PullRequest(filter, caller) => { - if verify_gossip_addr(&caller) { - pull_requests.push((from_addr, filter, caller)) + { + let _st_vec = ScopedTimer::from(&self.stats.populate_gossip_vectors_time); + for (from_addr, packet) in packets { + match packet { + Protocol::PullRequest(filter, caller) => { + if verify_gossip_addr(&caller) { + pull_requests.push((from_addr, filter, caller)) + } } - } - Protocol::PullResponse(_, mut data) => { - check_duplicate_instance(&data)?; - data.retain(|value| verify_incoming_crds_value(value, &mut verify_gossip_addr, &mut verify_node_instance)); - if !data.is_empty() { - pull_responses.append(&mut data); + Protocol::PullResponse(_, mut data) => { + check_duplicate_instance(&data)?; + data.retain(|value| verify_incoming_crds_value(value, &mut verify_gossip_addr, &mut verify_node_instance)); + if !data.is_empty() { + pull_responses.append(&mut data); + } } - } - Protocol::PushMessage(from, mut data) => { - check_duplicate_instance(&data)?; - data.retain(|value| verify_incoming_crds_value(value, &mut verify_gossip_addr, &mut verify_node_instance)); - if !data.is_empty() { - push_messages.push((from, data)); + Protocol::PushMessage(from, mut data) => { + check_duplicate_instance(&data)?; + data.retain(|value| verify_incoming_crds_value(value, &mut verify_gossip_addr, &mut verify_node_instance)); + if !data.is_empty() { + push_messages.push((from, data)); + } } + Protocol::PruneMessage(_from, data) => prune_messages.push(data), + Protocol::PingMessage(ping) => ping_messages.push((from_addr, ping)), + Protocol::PongMessage(pong) => pong_messages.push((from_addr, pong)), } - Protocol::PruneMessage(_from, data) => prune_messages.push(data), - Protocol::PingMessage(ping) => ping_messages.push((from_addr, ping)), - Protocol::PongMessage(pong) => pong_messages.push((from_addr, pong)), } - } - if self.require_stake_for_gossip(stakes) { - retain_staked(&mut pull_responses, stakes); - for (_, data) in &mut push_messages { - retain_staked(data, stakes); + if self.require_stake_for_gossip(stakes) { + retain_staked(&mut pull_responses, stakes); + for (_, data) in &mut push_messages { + retain_staked(data, stakes); + } + push_messages.retain(|(_, data)| !data.is_empty()); } - push_messages.retain(|(_, data)| !data.is_empty()); } if !pings.is_empty() { self.stats diff --git a/gossip/src/cluster_info_metrics.rs b/gossip/src/cluster_info_metrics.rs index 02eafeeeeb6cf3..252ad856c1297f 100644 --- a/gossip/src/cluster_info_metrics.rs +++ b/gossip/src/cluster_info_metrics.rs @@ -146,6 +146,7 @@ pub struct GossipStats { pub(crate) packets_sent_pull_responses_count: Counter, pub(crate) packets_sent_push_messages_count: Counter, pub(crate) process_gossip_packets_time: Counter, + pub(crate) populate_gossip_vectors_time: Counter, pub(crate) process_prune: Counter, pub(crate) process_pull_requests: Counter, pub(crate) process_pull_response: Counter, @@ -240,6 +241,11 @@ pub(crate) fn submit_gossip_stats( stats.process_gossip_packets_time.clear(), i64 ), + ( + "populate_gossip_vectors_time", + stats.populate_gossip_vectors_time.clear(), + i64 + ), ( "verify_gossip_packets_time", stats.verify_gossip_packets_time.clear(),