mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 12:11:59 +00:00
estimate the total inbound bandwidth of IDONTWANT messages in bytes (#6438)
* estimate the total inbound bandwidth of IDONTWANT messages
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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.
|
||||
@@ -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(
|
||||
@@ -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,
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user