Skip to content

Commit

Permalink
measure perf track overhead
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunwangs committed Mar 1, 2024
1 parent b12a19e commit caf6a3c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions streamer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ quinn = { workspace = true }
quinn-proto = { workspace = true }
rand = { workspace = true }
rustls = { workspace = true, features = ["dangerous_configuration"] }
solana-measure = { workspace = true }
solana-metrics = { workspace = true }
solana-perf = { workspace = true }
solana-sdk = { workspace = true }
Expand Down
6 changes: 6 additions & 0 deletions streamer/src/nonblocking/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use {
quinn::{Connecting, Connection, Endpoint, EndpointConfig, TokioRuntime, VarInt},
quinn_proto::VarIntBoundsExceeded,
rand::{thread_rng, Rng},
solana_measure::measure::Measure,
solana_perf::packet::{PacketBatch, PACKETS_PER_BATCH},
solana_sdk::{
packet::{Meta, PACKET_DATA_SIZE},
Expand Down Expand Up @@ -720,6 +721,7 @@ fn track_streamer_fetch_packet_performance(
if packet_perf_measure.is_empty() {
return;
}
let mut measure = Measure::start("track_perf");
let mut process_sampled_packets_us_hist = stats.process_sampled_packets_us_hist.lock().unwrap();

for (signature, start_time) in packet_perf_measure.iter() {
Expand All @@ -732,6 +734,10 @@ fn track_streamer_fetch_packet_performance(
.increment(duration.as_micros() as u64)
.unwrap();
}
measure.stop();
stats
.perf_track_overhead_us
.fetch_add(measure.as_us(), Ordering::Relaxed);
}

async fn handle_connection(
Expand Down
8 changes: 7 additions & 1 deletion streamer/src/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use {
std::{
net::UdpSocket,
sync::{
atomic::{AtomicBool, AtomicUsize, Ordering},
atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering},
Arc, Mutex, RwLock,
},
thread,
Expand Down Expand Up @@ -176,6 +176,7 @@ pub struct StreamStats {
pub(crate) stream_load_ema_overflow: AtomicUsize,
pub(crate) stream_load_capacity_overflow: AtomicUsize,
pub(crate) process_sampled_packets_us_hist: Mutex<histogram::Histogram>,
pub(crate) perf_track_overhead_us: AtomicU64,
}

impl StreamStats {
Expand Down Expand Up @@ -449,6 +450,11 @@ impl StreamStats {
process_sampled_packets_us_hist.mean().unwrap_or(0),
i64
),
(
"perf_track_overhead_us",
self.perf_track_overhead_us.swap(0, Ordering::Relaxed),
i64
),
);
}
}
Expand Down

0 comments on commit caf6a3c

Please sign in to comment.