Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak a retry number for piece retrieval operations on DSN L2. (#1910) #1912

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading