mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Further reduce the CPU overhead of networking metrics (#10875)
* Simplify `num_connected_peers` * Track requested peer counts * Revert "Track requested peer counts" This reverts commit 9f1c8704353df6afc17ed7e9f4ab8d8e29466ae4. * Remove `substrate_sub_libp2p_peerset_num_requested` metric * Remove two unused functions that I forgot to get rid of in previous commit
This commit is contained in:
@@ -465,12 +465,6 @@ impl<B: BlockT> Protocol<B> {
|
||||
self.behaviour.open_peers()
|
||||
}
|
||||
|
||||
/// Returns the list of all the peers that the peerset currently requests us to be connected
|
||||
/// to on the default set.
|
||||
pub fn requested_peers(&self) -> impl Iterator<Item = &PeerId> {
|
||||
self.behaviour.requested_peers(HARDCODED_PEERSETS_SYNC)
|
||||
}
|
||||
|
||||
/// Returns the number of discovered nodes that we keep in memory.
|
||||
pub fn num_discovered_peers(&self) -> usize {
|
||||
self.behaviour.num_discovered_peers()
|
||||
@@ -496,7 +490,7 @@ impl<B: BlockT> Protocol<B> {
|
||||
|
||||
/// Returns the number of peers we're connected to.
|
||||
pub fn num_connected_peers(&self) -> usize {
|
||||
self.peers.values().count()
|
||||
self.peers.len()
|
||||
}
|
||||
|
||||
/// Returns the number of peers we're connected to and that are being queried.
|
||||
|
||||
@@ -251,16 +251,6 @@ impl PeerState {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// True if that node has been requested by the PSM.
|
||||
fn is_requested(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Self::PendingRequest { .. } |
|
||||
Self::Requested | Self::DisabledPendingEnable { .. } |
|
||||
Self::Enabled { .. }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// State of the handler of a single connection visible from this state machine.
|
||||
@@ -560,17 +550,6 @@ impl Notifications {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the list of all the peers that the peerset currently requests us to be connected to.
|
||||
pub fn requested_peers<'a>(
|
||||
&'a self,
|
||||
set_id: sc_peerset::SetId,
|
||||
) -> impl Iterator<Item = &'a PeerId> + 'a {
|
||||
self.peers
|
||||
.iter()
|
||||
.filter(move |((_, set), state)| *set == set_id && state.is_requested())
|
||||
.map(|((id, _), _)| id)
|
||||
}
|
||||
|
||||
/// Returns the list of reserved peers.
|
||||
pub fn reserved_peers<'a>(
|
||||
&'a self,
|
||||
|
||||
@@ -2108,10 +2108,6 @@ impl<B: BlockT + 'static, H: ExHashT> Future for NetworkWorker<B, H> {
|
||||
.peerset_num_discovered
|
||||
.set(this.network_service.behaviour_mut().user_protocol().num_discovered_peers()
|
||||
as u64);
|
||||
metrics.peerset_num_requested.set(
|
||||
this.network_service.behaviour_mut().user_protocol().requested_peers().count()
|
||||
as u64,
|
||||
);
|
||||
metrics.pending_connections.set(
|
||||
Swarm::network_info(&this.network_service).connection_counters().num_pending()
|
||||
as u64,
|
||||
|
||||
@@ -69,7 +69,6 @@ pub struct Metrics {
|
||||
pub notifications_streams_closed_total: CounterVec<U64>,
|
||||
pub notifications_streams_opened_total: CounterVec<U64>,
|
||||
pub peerset_num_discovered: Gauge<U64>,
|
||||
pub peerset_num_requested: Gauge<U64>,
|
||||
pub pending_connections: Gauge<U64>,
|
||||
pub pending_connections_errors_total: CounterVec<U64>,
|
||||
pub requests_in_failure_total: CounterVec<U64>,
|
||||
@@ -204,10 +203,6 @@ impl Metrics {
|
||||
"substrate_sub_libp2p_peerset_num_discovered",
|
||||
"Number of nodes stored in the peerset manager",
|
||||
)?, registry)?,
|
||||
peerset_num_requested: prometheus::register(Gauge::new(
|
||||
"substrate_sub_libp2p_peerset_num_requested",
|
||||
"Number of nodes that the peerset manager wants us to be connected to",
|
||||
)?, registry)?,
|
||||
pending_connections: prometheus::register(Gauge::new(
|
||||
"substrate_sub_libp2p_pending_connections",
|
||||
"Number of connections in the process of being established",
|
||||
|
||||
Reference in New Issue
Block a user