Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Further reduce the CPU overhead of networking metrics #10875

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions client/network/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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.
Expand Down
21 changes: 0 additions & 21 deletions client/network/src/protocol/notifications/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions client/network/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions client/network/src/service/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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",
Expand Down