Skip to content

Commit

Permalink
Merge pull request #1912 from subspace/tweak-l2-retries-number
Browse files Browse the repository at this point in the history
Tweak a retry number for piece retrieval operations on DSN L2. (#1910)
  • Loading branch information
nazar-pc committed Aug 31, 2023
2 parents a56afdc + f216889 commit a5336b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions crates/subspace-farmer/src/piece_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use parking_lot::RwLock;
use rayon::prelude::*;
use std::collections::HashMap;
use std::mem;
use std::num::NonZeroU16;
use std::sync::Arc;
use subspace_core_primitives::{Piece, PieceIndex, SegmentIndex};
use subspace_farmer_components::plotting::{PieceGetter, PieceGetterRetryPolicy};
Expand All @@ -20,6 +21,8 @@ const WORKER_CHANNEL_CAPACITY: usize = 100;
/// Make caches available as they are building without waiting for the initialization to finish,
/// this number defines an interval in pieces after which cache is updated
const INTERMEDIATE_CACHE_UPDATE_INTERVAL: usize = 100;
/// Get piece retry attempts number.
const PIECE_GETTER_RETRY_NUMBER: NonZeroU16 = NonZeroU16::new(3).expect("Not zero; qed");

#[derive(Debug, Clone)]
struct DiskPieceCacheState {
Expand Down Expand Up @@ -255,7 +258,10 @@ where
// TODO: Can probably do concurrency here
for (index, piece_index) in piece_indices_to_store.into_values().enumerate() {
let result = piece_getter
.get_piece(piece_index, PieceGetterRetryPolicy::Limited(1))
.get_piece(
piece_index,
PieceGetterRetryPolicy::Limited(PIECE_GETTER_RETRY_NUMBER.get()),
)
.await;

let piece = match result {
Expand Down Expand Up @@ -432,7 +438,10 @@ where
trace!(%piece_index, "Piece needs to be cached #1");

let result = piece_getter
.get_piece(piece_index, PieceGetterRetryPolicy::Limited(1))
.get_piece(
piece_index,
PieceGetterRetryPolicy::Limited(PIECE_GETTER_RETRY_NUMBER.get()),
)
.await;

let piece = match result {
Expand Down
4 changes: 2 additions & 2 deletions crates/subspace-farmer/src/single_disk_farm/plotting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ use thiserror::Error;
use tracing::{debug, info, trace, warn};

const FARMER_APP_INFO_RETRY_INTERVAL: Duration = Duration::from_millis(500);
/// Get piece retry attempts number.
const PIECE_GETTER_RETRY_NUMBER: NonZeroU16 = NonZeroU16::new(3).expect("Not zero; qed");
/// Size of the cache of archived segments for the purposes of faster sector expiration checks.
const ARCHIVED_SEGMENTS_CACHE_SIZE: NonZeroUsize = NonZeroUsize::new(1000).expect("Not zero; qed");
/// Get piece retry attempts number.
const PIECE_GETTER_RETRY_NUMBER: NonZeroU16 = NonZeroU16::new(3).expect("Not zero; qed");

/// Errors that happen during plotting
#[derive(Debug, Error)]
Expand Down

0 comments on commit a5336b5

Please sign in to comment.