Skip to content

Commit b718154

Browse files
committed
[State Sync] Small config tweaks and metrics improvements.
1 parent ea87584 commit b718154

File tree

4 files changed

+47
-19
lines changed

4 files changed

+47
-19
lines changed

config/src/config/network_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub const PING_FAILURES_TOLERATED: u64 = 5;
3939
pub const CONNECTIVITY_CHECK_INTERVAL_MS: u64 = 5000;
4040
pub const MAX_CONCURRENT_NETWORK_REQS: usize = 100;
4141
pub const MAX_CONNECTION_DELAY_MS: u64 = 60_000; /* 1 minute */
42-
pub const MAX_FULLNODE_OUTBOUND_CONNECTIONS: usize = 5;
42+
pub const MAX_FULLNODE_OUTBOUND_CONNECTIONS: usize = 4;
4343
pub const MAX_INBOUND_CONNECTIONS: usize = 100;
4444
pub const MAX_FRAME_SIZE: usize = 16 * 1024 * 1024; /* 16 MiB */
4545
pub const CONNECTION_BACKOFF_BASE: u64 = 2;

config/src/config/state_sync_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl Default for DataStreamingServiceConfig {
186186
fn default() -> Self {
187187
Self {
188188
global_summary_refresh_interval_ms: 50,
189-
max_concurrent_requests: 3,
189+
max_concurrent_requests: 2,
190190
max_data_stream_channel_sizes: 1000,
191191
max_request_retry: 3,
192192
max_notification_id_mappings: 2000,

state-sync/aptos-data-client/src/aptosnet/metrics.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ pub static IN_FLIGHT_POLLS: Lazy<IntGaugeVec> = Lazy::new(|| {
6464
.unwrap()
6565
});
6666

67+
/// Gauge for tracking the number of connected peers (priority and regular)
68+
pub static CONNECTED_PEERS: Lazy<IntGaugeVec> = Lazy::new(|| {
69+
register_int_gauge_vec!(
70+
"aptos_data_client_connected_peers",
71+
"Gauge related to the number of connected peers",
72+
&["peer_type"]
73+
)
74+
.unwrap()
75+
});
76+
6777
/// Gauge for the highest advertised data
6878
pub static HIGHEST_ADVERTISED_DATA: Lazy<IntGaugeVec> = Lazy::new(|| {
6979
register_int_gauge_vec!(
@@ -140,8 +150,8 @@ pub fn increment_request_counter(
140150
}
141151

142152
/// Sets the gauge with the specific label and value
143-
pub fn set_gauge(counter: &Lazy<IntGaugeVec>, label: String, value: u64) {
144-
counter.with_label_values(&[&label]).set(value as i64);
153+
pub fn set_gauge(counter: &Lazy<IntGaugeVec>, label: &str, value: u64) {
154+
counter.with_label_values(&[label]).set(value as i64);
145155
}
146156

147157
/// Starts the timer for the provided histogram and label values.

state-sync/aptos-data-client/src/aptosnet/mod.rs

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,7 @@ impl AptosNetDataClient {
281281
// Log the peers, periodically.
282282
sample!(
283283
SampleRate::Duration(Duration::from_secs(PEER_LOG_FREQ_SECS)),
284-
info!(
285-
(LogSchema::new(LogEntry::PeerStates)
286-
.event(LogEvent::PriorityAndRegularPeers)
287-
.message(&format!(
288-
"Number of priority peers: {:?}. Number of regular peers: {:?}",
289-
priority_peers.len(), regular_peers.len(),
290-
)))
291-
);
284+
update_connected_peer_metrics(priority_peers.len(), regular_peers.len());
292285
);
293286

294287
Ok((priority_peers, regular_peers))
@@ -701,12 +694,37 @@ fn update_in_flight_metrics(label: &str, num_in_flight_polls: u64) {
701694
SampleRate::Frequency(IN_FLIGHT_METRICS_SAMPLE_FREQ),
702695
set_gauge(
703696
&metrics::IN_FLIGHT_POLLS,
704-
label.into(),
697+
label,
705698
num_in_flight_polls,
706699
);
707700
);
708701
}
709702

703+
/// Updates the metrics for the number of connected peers (priority and regular)
704+
fn update_connected_peer_metrics(num_priority_peers: usize, num_regular_peers: usize) {
705+
// Log the number of connected peers
706+
info!(
707+
(LogSchema::new(LogEntry::PeerStates)
708+
.event(LogEvent::PriorityAndRegularPeers)
709+
.message(&format!(
710+
"Number of priority peers: {:?}. Number of regular peers: {:?}",
711+
num_priority_peers, num_regular_peers,
712+
)))
713+
);
714+
715+
// Update the connected peer metrics
716+
set_gauge(
717+
&metrics::CONNECTED_PEERS,
718+
PRIORITIZED_PEER,
719+
num_priority_peers as u64,
720+
);
721+
set_gauge(
722+
&metrics::CONNECTED_PEERS,
723+
REGULAR_PEER,
724+
num_regular_peers as u64,
725+
);
726+
}
727+
710728
/// Spawns a dedicated poller for the given peer.
711729
pub(crate) fn poll_peer(
712730
data_client: AptosNetDataClient,
@@ -793,9 +811,9 @@ fn update_advertised_data_metrics(global_data_summary: GlobalDataSummary) {
793811
DataType::TransactionOutputs => optimal_chunk_sizes.transaction_output_chunk_size,
794812
DataType::Transactions => optimal_chunk_sizes.transaction_chunk_size,
795813
};
796-
metrics::set_gauge(
814+
set_gauge(
797815
&metrics::OPTIMAL_CHUNK_SIZES,
798-
data_type.as_str().into(),
816+
data_type.as_str(),
799817
optimal_chunk_size,
800818
);
801819
}
@@ -807,9 +825,9 @@ fn update_advertised_data_metrics(global_data_summary: GlobalDataSummary) {
807825
.map(|ledger_info| ledger_info.ledger_info().version());
808826
if let Some(highest_advertised_version) = highest_advertised_version {
809827
for data_type in DataType::get_all_types() {
810-
metrics::set_gauge(
828+
set_gauge(
811829
&metrics::HIGHEST_ADVERTISED_DATA,
812-
data_type.as_str().into(),
830+
data_type.as_str(),
813831
highest_advertised_version,
814832
);
815833
}
@@ -824,9 +842,9 @@ fn update_advertised_data_metrics(global_data_summary: GlobalDataSummary) {
824842
DataType::Transactions => advertised_data.lowest_transaction_version(),
825843
};
826844
if let Some(lowest_advertised_version) = lowest_advertised_version {
827-
metrics::set_gauge(
845+
set_gauge(
828846
&metrics::LOWEST_ADVERTISED_DATA,
829-
data_type.as_str().into(),
847+
data_type.as_str(),
830848
lowest_advertised_version,
831849
);
832850
}

0 commit comments

Comments
 (0)