Skip to content

Commit e9e31da

Browse files
authored
Merge pull request #3292 from autonomys/randomize-replotting-start
Randomize replotting start
2 parents 07a3f4e + fb5f06b commit e9e31da

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

crates/subspace-farmer/src/single_disk_farm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const_assert!(mem::size_of::<usize>() >= mem::size_of::<u64>());
9393
const RESERVED_PLOT_METADATA: u64 = 1024 * 1024;
9494
/// Reserve 1M of space for farm info (for potential future expansion)
9595
const RESERVED_FARM_INFO: u64 = 1024 * 1024;
96-
const NEW_SEGMENT_PROCESSING_DELAY: Duration = Duration::from_secs(30);
96+
const NEW_SEGMENT_PROCESSING_DELAY: Duration = Duration::from_mins(10);
9797

9898
/// Exclusive lock for single disk farm info file, ensuring no concurrent edits by cooperating processes is done
9999
#[derive(Debug)]

crates/subspace-farmer/src/single_disk_farm/plotting.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use futures::channel::{mpsc, oneshot};
1111
use futures::stream::FuturesOrdered;
1212
use futures::{select, FutureExt, SinkExt, StreamExt};
1313
use parity_scale_codec::Encode;
14+
use rand::prelude::*;
1415
use std::collections::HashSet;
1516
use std::future::Future;
1617
use std::io;
@@ -700,8 +701,8 @@ pub(super) struct PlottingSchedulerOptions<NC> {
700701
pub(super) handlers: Arc<Handlers>,
701702
pub(super) sectors_metadata: Arc<AsyncRwLock<Vec<SectorMetadataChecksummed>>>,
702703
pub(super) sectors_to_plot_sender: mpsc::Sender<SectorToPlot>,
703-
// Delay between segment header being acknowledged by farmer and potentially triggering
704-
// replotting
704+
// Max delay between segment header being acknowledged by farmer and potentially
705+
// triggering replotting
705706
pub(super) new_segment_processing_delay: Duration,
706707
pub(super) metrics: Option<Arc<SingleDiskFarmMetrics>>,
707708
}
@@ -798,7 +799,10 @@ where
798799

799800
// There is no urgent need to rush replotting sectors immediately and this delay allows for
800801
// newly archived pieces to be both cached locally and on other farmers on the network
801-
tokio::time::sleep(new_segment_processing_delay).await;
802+
let delay = Duration::from_secs(thread_rng().gen_range(
803+
new_segment_processing_delay.as_secs() / 10..=new_segment_processing_delay.as_secs(),
804+
));
805+
tokio::time::sleep(delay).await;
802806

803807
if archived_segments_sender.send(segment_header).is_err() {
804808
break;

0 commit comments

Comments
 (0)