From 7efb0bf1b3012c9fbc67146b4a06f90c7cdb6aeb Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Sun, 20 Aug 2023 10:49:05 +0300 Subject: [PATCH 1/2] Inherit parent span when scrubbing sectors and piece cache --- crates/subspace-farmer/src/single_disk_farm.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/subspace-farmer/src/single_disk_farm.rs b/crates/subspace-farmer/src/single_disk_farm.rs index 2d37a4b32b..fecee3ffca 100644 --- a/crates/subspace-farmer/src/single_disk_farm.rs +++ b/crates/subspace-farmer/src/single_disk_farm.rs @@ -1233,6 +1233,8 @@ impl SingleDiskFarm { /// Check the farm for corruption and repair errors (caused by disk errors or something else), /// returns an error when irrecoverable errors occur. pub fn scrub(directory: &Path) -> Result<(), SingleDiskFarmScrubError> { + let span = Span::current(); + let info = { let file = directory.join(SingleDiskFarmInfo::FILE_NAME); info!(path = %file.display(), "Checking info file"); @@ -1445,6 +1447,8 @@ impl SingleDiskFarm { (sector_metadata_bytes, piece) }, |(sector_metadata_bytes, piece), sector_index| { + let _span_guard = span.enter(); + let offset = RESERVED_PLOT_METADATA + u64::from(sector_index) * sector_metadata_size as u64; if let Err(error) = metadata_file.read_exact_at(sector_metadata_bytes, offset) { @@ -1628,9 +1632,12 @@ impl SingleDiskFarm { }, ) .try_for_each({ + let span = &span; let checked_sectors = AtomicUsize::new(0); move |result| { + let _span_guard = span.enter(); + let checked_sectors = checked_sectors.fetch_add(1, Ordering::Relaxed); if checked_sectors > 1 && checked_sectors % 10 == 0 { info!( @@ -1677,6 +1684,8 @@ impl SingleDiskFarm { (0..number_of_cached_elements) .into_par_iter() .map_with(vec![0; element_size], |element, cache_offset| { + let _span_guard = span.enter(); + let offset = cache_offset * element_size as u64; if let Err(error) = cache_file.read_exact_at(element, offset) { warn!( @@ -1726,9 +1735,12 @@ impl SingleDiskFarm { Ok(()) }) .try_for_each({ + let span = &span; let checked_elements = AtomicUsize::new(0); move |result| { + let _span_guard = span.enter(); + let checked_elements = checked_elements.fetch_add(1, Ordering::Relaxed); if checked_elements > 1 && checked_elements % 1000 == 0 { info!( From e2a5c1491fc38a7cbb6e0e954ce39180dbfbc00b Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Sun, 20 Aug 2023 11:05:10 +0300 Subject: [PATCH 2/2] Print plotting progress in % during successful sector plotting --- crates/subspace-farmer/src/single_disk_farm.rs | 1 + crates/subspace-farmer/src/single_disk_farm/plotting.rs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/subspace-farmer/src/single_disk_farm.rs b/crates/subspace-farmer/src/single_disk_farm.rs index fecee3ffca..130fa73c3d 100644 --- a/crates/subspace-farmer/src/single_disk_farm.rs +++ b/crates/subspace-farmer/src/single_disk_farm.rs @@ -899,6 +899,7 @@ impl SingleDiskFarm { erasure_coding, handlers, modifying_sector_index, + target_sector_count, sectors_to_plot_receiver, ) .await diff --git a/crates/subspace-farmer/src/single_disk_farm/plotting.rs b/crates/subspace-farmer/src/single_disk_farm/plotting.rs index 011b964f04..a60488bd23 100644 --- a/crates/subspace-farmer/src/single_disk_farm/plotting.rs +++ b/crates/subspace-farmer/src/single_disk_farm/plotting.rs @@ -94,6 +94,7 @@ pub(super) async fn plotting( erasure_coding: ErasureCoding, handlers: Arc, modifying_sector_index: Arc>>, + target_sector_count: u16, mut sectors_to_plot: mpsc::Receiver<(SectorIndex, oneshot::Sender<()>)>, ) -> Result<(), PlottingError> where @@ -225,7 +226,11 @@ where if maybe_old_plotted_sector.is_some() { info!(%sector_index, "Sector replotted successfully"); } else { - info!(%sector_index, "Sector plotted successfully"); + info!( + %sector_index, + "Sector plotted successfully ({:.2}%)", + (sector_index + 1) as f32 / target_sector_count as f32 * 100.0 + ); } handlers