Skip to content

Commit

Permalink
add timer measuring time to populate gossip message vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
gregcusack committed Aug 8, 2024
1 parent 4c079c2 commit 5162e9b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 26 deletions.
55 changes: 29 additions & 26 deletions gossip/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions gossip/src/cluster_info_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 5162e9b

Please sign in to comment.