Skip to content

Commit

Permalink
networking: Increase yamux buffers.
Browse files Browse the repository at this point in the history
  • Loading branch information
shamil-gadelshin committed Oct 27, 2023
1 parent fa9bf51 commit 84a19d8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/subspace-networking/src/constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 84a19d8

Please sign in to comment.