From d0b1f2c7c0ac90543ed6935f65b7cfc4673f74da Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:52:46 -0600 Subject: [PATCH] v1.17: Show staked vs nonstaked packets sent down/throttled (backport of #600) (#613) * Show staked vs nonstaked packets sent down/throttled (#600) * Show staked vs nonstaked packets sent down * add metrics on throttled staked vs non-staked (cherry picked from commit b443cfb0c7b223e8249219db32be5ed8fa83c629) # Conflicts: # streamer/src/quic.rs * fix merge conflicts --------- Co-authored-by: Lijun Wang <83639177+lijunwangs@users.noreply.github.com> Co-authored-by: HaoranYi --- streamer/src/nonblocking/quic.rs | 25 +++++++++++++++++++++++++ streamer/src/quic.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/streamer/src/nonblocking/quic.rs b/streamer/src/nonblocking/quic.rs index a3d2d4fa16a691..38200ea15fe71a 100644 --- a/streamer/src/nonblocking/quic.rs +++ b/streamer/src/nonblocking/quic.rs @@ -798,6 +798,18 @@ async fn handle_connection( streams_in_current_interval = 0; } else if streams_in_current_interval >= max_streams_per_100ms { stats.throttled_streams.fetch_add(1, Ordering::Relaxed); + match peer_type { + ConnectionPeerType::Unstaked => { + stats + .throttled_unstaked_streams + .fetch_add(1, Ordering::Relaxed); + } + ConnectionPeerType::Staked => { + stats + .throttled_staked_streams + .fetch_add(1, Ordering::Relaxed); + } + } let _ = stream.stop(VarInt::from_u32(STREAM_STOP_CODE_THROTTLING)); continue; } @@ -966,6 +978,19 @@ async fn handle_chunk( .total_chunks_sent_for_batching .fetch_add(chunks_sent, Ordering::Relaxed); + match peer_type { + ConnectionPeerType::Unstaked => { + stats + .total_unstaked_packets_sent_for_batching + .fetch_add(1, Ordering::Relaxed); + } + ConnectionPeerType::Staked => { + stats + .total_staked_packets_sent_for_batching + .fetch_add(1, Ordering::Relaxed); + } + } + trace!("sent {} byte packet for batching", bytes_sent); } } else { diff --git a/streamer/src/quic.rs b/streamer/src/quic.rs index 8b2b4f9d852cac..1ac2be7f7ed0aa 100644 --- a/streamer/src/quic.rs +++ b/streamer/src/quic.rs @@ -157,6 +157,10 @@ pub struct StreamStats { pub(crate) connection_removed: AtomicUsize, pub(crate) connection_remove_failed: AtomicUsize, pub(crate) throttled_streams: AtomicUsize, + pub(crate) total_staked_packets_sent_for_batching: AtomicUsize, + pub(crate) total_unstaked_packets_sent_for_batching: AtomicUsize, + pub(crate) throttled_staked_streams: AtomicUsize, + pub(crate) throttled_unstaked_streams: AtomicUsize, } impl StreamStats { @@ -311,6 +315,18 @@ impl StreamStats { .swap(0, Ordering::Relaxed), i64 ), + ( + "staked_packets_sent_for_batching", + self.total_staked_packets_sent_for_batching + .swap(0, Ordering::Relaxed), + i64 + ), + ( + "unstaked_packets_sent_for_batching", + self.total_unstaked_packets_sent_for_batching + .swap(0, Ordering::Relaxed), + i64 + ), ( "bytes_sent_for_batching", self.total_bytes_sent_for_batching @@ -392,6 +408,16 @@ impl StreamStats { self.throttled_streams.swap(0, Ordering::Relaxed), i64 ), + ( + "throttled_unstaked_streams", + self.throttled_unstaked_streams.swap(0, Ordering::Relaxed), + i64 + ), + ( + "throttled_staked_streams", + self.throttled_staked_streams.swap(0, Ordering::Relaxed), + i64 + ), ); } }