Skip to content

Commit

Permalink
add in gossip_crds_sample_pull and gossip_crds_sample_fail to track r…
Browse files Browse the repository at this point in the history
…edundant pulls
  • Loading branch information
gregcusack committed Mar 6, 2024
1 parent 3f9a7a5 commit 298964f
Showing 1 changed file with 54 additions and 25 deletions.
79 changes: 54 additions & 25 deletions gossip/src/crds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,36 +677,39 @@ impl CrdsDataStats {
}
}

if let GossipRoute::PushMessage(from) = route {
if should_report_message_signature(&entry.value.signature) {
report_gossip_crds_sample_push("gossip_crds_sample", entry, from);
}
} else if let GossipRoute::PullResponse = route {
if should_report_message_signature(&entry.value.signature) {
datapoint_info!(
"gossip_crds_sample_pull",
(
"origin",
entry.value.pubkey().to_string().get(..8),
Option<String>
),
(
"signature",
entry.value.signature.to_string().get(..8),
Option<String>
)
);
}
}
}

fn record_fail(&mut self, entry: &VersionedCrdsValue, route: GossipRoute) {
self.fails[Self::ordinal(entry)] += 1;
let GossipRoute::PushMessage(from) = route else {
return;
};

if should_report_message_signature(&entry.value.signature) {
datapoint_info!(
"gossip_crds_sample",
(
"origin",
entry.value.pubkey().to_string().get(..8),
Option<String>
),
(
"signature",
entry.value.signature.to_string().get(..8),
Option<String>
),
(
"from",
from.to_string().get(..8),
Option<String>
)
);
report_gossip_crds_sample_push("gossip_crds_sample_fail", entry, from);
}
}

fn record_fail(&mut self, entry: &VersionedCrdsValue) {
self.fails[Self::ordinal(entry)] += 1;
}

fn ordinal(entry: &VersionedCrdsValue) -> usize {
match &entry.value.data {
CrdsData::LegacyContactInfo(_) => 0,
Expand Down Expand Up @@ -742,8 +745,8 @@ impl CrdsStats {
match route {
GossipRoute::LocalMessage => (),
GossipRoute::PullRequest => (),
GossipRoute::PushMessage(_) => self.push.record_fail(entry),
GossipRoute::PullResponse => self.pull.record_fail(entry),
GossipRoute::PushMessage(_) => self.push.record_fail(entry, route),
GossipRoute::PullResponse => self.pull.record_fail(entry, route),
}
}
}
Expand All @@ -757,6 +760,32 @@ fn should_report_message_signature(signature: &Signature) -> bool {
u64::from_le_bytes(bytes).trailing_zeros() >= SIGNATURE_SAMPLE_LEADING_ZEROS
}

#[inline]
fn report_gossip_crds_sample_push(
metric_label: &'static str,
entry: &VersionedCrdsValue,
from: &Pubkey,
) {
datapoint_info!(
metric_label,
(
"origin",
entry.value.pubkey().to_string().get(..8),
Option<String>
),
(
"signature",
entry.value.signature.to_string().get(..8),
Option<String>
),
(
"from",
from.to_string().get(..8),
Option<String>
)
);
}

#[cfg(test)]
mod tests {
use {
Expand Down

0 comments on commit 298964f

Please sign in to comment.