From b44c9bca898122bd3b6de24770c2a0acd31da222 Mon Sep 17 00:00:00 2001 From: Lijun Wang <83639177+lijunwangs@users.noreply.github.com> Date: Tue, 15 Aug 2023 12:02:58 -0700 Subject: [PATCH] Reduce max staked streams count to avoid fragmentations (#32771) Reduce max staked concurrent streams to 512 from 2048. --- sdk/src/quic.rs | 7 +++++-- streamer/src/nonblocking/quic.rs | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sdk/src/quic.rs b/sdk/src/quic.rs index d7bfc201cb..dd75efccf7 100644 --- a/sdk/src/quic.rs +++ b/sdk/src/quic.rs @@ -10,8 +10,11 @@ pub const QUIC_MIN_STAKED_CONCURRENT_STREAMS: usize = 128; pub const QUIC_TOTAL_STAKED_CONCURRENT_STREAMS: usize = 100_000; -// Set the maximum concurrent stream numbers to avoid excessive streams -pub const QUIC_MAX_STAKED_CONCURRENT_STREAMS: usize = 2048; +// Set the maximum concurrent stream numbers to avoid excessive streams. +// The value was lowered from 2048 to reduce contention of the limited +// receive_window among the streams which is observed in CI bench-tests with +// forwarded packets from staked nodes. +pub const QUIC_MAX_STAKED_CONCURRENT_STREAMS: usize = 512; pub const QUIC_MAX_TIMEOUT: Duration = Duration::from_secs(2); pub const QUIC_KEEP_ALIVE: Duration = Duration::from_secs(1); diff --git a/streamer/src/nonblocking/quic.rs b/streamer/src/nonblocking/quic.rs index ecdcb0bc2b..7347b2cd78 100644 --- a/streamer/src/nonblocking/quic.rs +++ b/streamer/src/nonblocking/quic.rs @@ -1934,7 +1934,8 @@ pub mod test { ); assert_eq!( compute_max_allowed_uni_streams(ConnectionPeerType::Staked, 100, 10000), - (delta / (100_f64)) as usize + QUIC_MIN_STAKED_CONCURRENT_STREAMS + ((delta / (100_f64)) as usize + QUIC_MIN_STAKED_CONCURRENT_STREAMS) + .min(QUIC_MAX_STAKED_CONCURRENT_STREAMS) ); assert_eq!( compute_max_allowed_uni_streams(ConnectionPeerType::Staked, 0, 10000),