Skip to content

Commit

Permalink
estimate the total inbound bandwidth of IDONTWANT messages in bytes (s…
Browse files Browse the repository at this point in the history
…igp#6438)

* estimate the total inbound bandwidth of IDONTWANT messages
  • Loading branch information
jxs authored Oct 1, 2024
1 parent 82098e1 commit 4a62b24
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions beacon_node/lighthouse_network/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3348,6 +3348,8 @@ where
};
if let Some(metrics) = self.metrics.as_mut() {
metrics.register_idontwant(message_ids.len());
let idontwant_size = message_ids.iter().map(|id| id.0.len()).sum();
metrics.register_idontwant_bytes(idontwant_size);
}
for message_id in message_ids {
peer.dont_send.insert(message_id, Instant::now());
Expand Down
19 changes: 19 additions & 0 deletions beacon_node/lighthouse_network/gossipsub/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ pub(crate) struct Metrics {
/// The number of msg_id's we have received in every IDONTWANT control message.
idontwant_msgs_ids: Counter,

/// The number of bytes we have received in every IDONTWANT control message.
idontwant_bytes: Counter,

/// The size of the priority queue.
priority_queue_size: Histogram,
/// The size of the non-priority queue.
Expand Down Expand Up @@ -338,6 +341,16 @@ impl Metrics {
metric
};

let idontwant_bytes = {
let metric = Counter::default();
registry.register(
"idontwant_bytes",
"The total bytes we have received an IDONTWANT control messages",
metric.clone(),
);
metric
};

let memcache_misses = {
let metric = Counter::default();
registry.register(
Expand Down Expand Up @@ -390,6 +403,7 @@ impl Metrics {
memcache_misses,
topic_iwant_msgs,
idontwant_msgs,
idontwant_bytes,
idontwant_msgs_ids,
priority_queue_size,
non_priority_queue_size,
Expand Down Expand Up @@ -589,6 +603,11 @@ impl Metrics {
}
}

/// Register receiving the total bytes of an IDONTWANT control message.
pub(crate) fn register_idontwant_bytes(&mut self, bytes: usize) {
self.idontwant_bytes.inc_by(bytes as u64);
}

/// Register receiving an IDONTWANT msg for this topic.
pub(crate) fn register_idontwant(&mut self, msgs: usize) {
self.idontwant_msgs.inc();
Expand Down

0 comments on commit 4a62b24

Please sign in to comment.