Skip to content

Commit

Permalink
Merge pull request #1930 from subspace/backport-tuning-piece-retrieva…
Browse files Browse the repository at this point in the history
…l-params

Tune piece retrieval parameters for DSN (gemini-3f backport).
  • Loading branch information
nazar-pc authored Sep 5, 2023
2 parents 4f3b13e + 56afb1b commit 117e99d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions crates/subspace-farmer/src/bin/subspace-farmer/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ struct DsnArgs {
#[arg(long, default_value_t = 50)]
in_connections: u32,
/// Defines max established outgoing swarm connection limit.
#[arg(long, default_value_t = 50)]
#[arg(long, default_value_t = 100)]
out_connections: u32,
/// Defines max pending incoming connection limit.
#[arg(long, default_value_t = 50)]
pending_in_connections: u32,
/// Defines max pending outgoing swarm connection limit.
#[arg(long, default_value_t = 50)]
#[arg(long, default_value_t = 100)]
pending_out_connections: u32,
/// Defines target total (in and out) connection number that should be maintained.
#[arg(long, default_value_t = 50)]
Expand Down
4 changes: 2 additions & 2 deletions crates/subspace-networking/src/constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ const SPECIAL_CONNECTED_PEERS_PROTOCOL_LOG_TARGET: &str = "special-connected-pee
// It must be set for large plots.
const SWARM_MAX_NEGOTIATING_INBOUND_STREAMS: usize = 100000;
/// The default maximum established incoming connection number for the swarm.
const SWARM_MAX_ESTABLISHED_INCOMING_CONNECTIONS: u32 = 80;
const SWARM_MAX_ESTABLISHED_INCOMING_CONNECTIONS: u32 = 100;
/// The default maximum established incoming connection number for the swarm.
const SWARM_MAX_ESTABLISHED_OUTGOING_CONNECTIONS: u32 = 80;
const SWARM_MAX_ESTABLISHED_OUTGOING_CONNECTIONS: u32 = 100;
/// The default maximum pending incoming connection number for the swarm.
const SWARM_MAX_PENDING_INCOMING_CONNECTIONS: u32 = 80;
/// The default maximum pending incoming connection number for the swarm.
Expand Down
3 changes: 2 additions & 1 deletion crates/subspace-networking/src/utils/piece_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use subspace_core_primitives::{Piece, PieceIndex};
use tracing::{debug, trace, warn};

/// Defines initial duration between get_piece calls.
const GET_PIECE_INITIAL_INTERVAL: Duration = Duration::from_secs(3);
const GET_PIECE_INITIAL_INTERVAL: Duration = Duration::from_secs(5);
/// Defines max duration between get_piece calls.
const GET_PIECE_MAX_INTERVAL: Duration = Duration::from_secs(40);

Expand Down Expand Up @@ -132,6 +132,7 @@ where
max_interval: GET_PIECE_MAX_INTERVAL,
// Try until we get a valid piece
max_elapsed_time: None,
multiplier: 1.75,
..ExponentialBackoff::default()
};

Expand Down
1 change: 1 addition & 0 deletions crates/subspace-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
#![feature(
const_option,
impl_trait_in_assoc_type,
int_roundings,
type_alias_impl_trait,
Expand Down
9 changes: 8 additions & 1 deletion crates/subspace-service/src/sync_from_dsn/import_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use sc_tracing::tracing::{debug, trace};
use sp_consensus::BlockOrigin;
use sp_runtime::traits::{Block as BlockT, Header, NumberFor, One};
use sp_runtime::Saturating;
use std::num::NonZeroU16;
use std::time::Duration;
use subspace_archiving::reconstructor::Reconstructor;
use subspace_core_primitives::{
Expand All @@ -34,6 +35,9 @@ use subspace_networking::utils::piece_provider::{PieceProvider, PieceValidator,
use tokio::sync::Semaphore;
use tracing::warn;

/// Get piece retry attempts number.
const PIECE_GETTER_RETRY_NUMBER: NonZeroU16 = NonZeroU16::new(3).expect("Not zero; qed");

/// How many blocks to queue before pausing and waiting for blocks to be imported, this is
/// essentially used to ensure we use a bounded amount of RAM during sync process.
const QUEUED_BLOCKS_LIMIT: BlockNumber = 500;
Expand Down Expand Up @@ -269,7 +273,10 @@ where
}
};
let maybe_piece = match piece_provider
.get_piece(piece_index, RetryPolicy::Limited(0))
.get_piece(
piece_index,
RetryPolicy::Limited(PIECE_GETTER_RETRY_NUMBER.get()),
)
.await
{
Ok(maybe_piece) => maybe_piece,
Expand Down

0 comments on commit 117e99d

Please sign in to comment.