From 84a19d82af85c3b5f6eca9b1e720c1a36d86f5a8 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Fri, 27 Oct 2023 17:56:30 +0700 Subject: [PATCH] networking: Increase yamux buffers. --- crates/subspace-networking/src/constructor.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/subspace-networking/src/constructor.rs b/crates/subspace-networking/src/constructor.rs index dadf0ca96b..4be858158f 100644 --- a/crates/subspace-networking/src/constructor.rs +++ b/crates/subspace-networking/src/constructor.rs @@ -87,6 +87,13 @@ const TEMPORARY_BANS_DEFAULT_BACKOFF_RANDOMIZATION_FACTOR: f64 = 0.1; const TEMPORARY_BANS_DEFAULT_BACKOFF_MULTIPLIER: f64 = 1.5; const TEMPORARY_BANS_DEFAULT_MAX_INTERVAL: Duration = Duration::from_secs(30 * 60); +/// Specific YAMUX settings for Subspace applications: additional buffer space for pieces. +/// +/// 1MB of piece + original value (1 MB) +const YAMUX_BUFFER_SIZE: usize = Piece::SIZE + 1024 * 1024; +/// 1MB of piece + original value (256 KB) +const YAMUX_RECEIVING_WINDOW: usize = Piece::SIZE + 256 * 1024; + /// Max confidence for autonat protocol. Could affect Kademlia mode change. pub(crate) const AUTONAT_MAX_CONFIDENCE: usize = 3; @@ -296,7 +303,10 @@ where .set_replication_interval(None); let mut yamux_config = YamuxConfig::default(); - yamux_config.set_max_num_streams(YAMUX_MAX_STREAMS); + yamux_config + .set_max_num_streams(YAMUX_MAX_STREAMS) + .set_receive_window_size(YAMUX_RECEIVING_WINDOW as u32) + .set_max_buffer_size(YAMUX_BUFFER_SIZE); let gossipsub = ENABLE_GOSSIP_PROTOCOL.then(|| { GossipsubConfigBuilder::default()