Skip to content

Commit

Permalink
Merge pull request #1851 from subspace/tiny-ux-improvements
Browse files Browse the repository at this point in the history
Tiny UX improvements
  • Loading branch information
nazar-pc authored Aug 21, 2023
2 parents c93e9f5 + e2a5c14 commit 8749269
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
13 changes: 13 additions & 0 deletions crates/subspace-farmer/src/single_disk_farm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@ impl SingleDiskFarm {
erasure_coding,
handlers,
modifying_sector_index,
target_sector_count,
sectors_to_plot_receiver,
)
.await
Expand Down Expand Up @@ -1233,6 +1234,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");
Expand Down Expand Up @@ -1445,6 +1448,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) {
Expand Down Expand Up @@ -1628,9 +1633,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!(
Expand Down Expand Up @@ -1677,6 +1685,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!(
Expand Down Expand Up @@ -1726,9 +1736,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!(
Expand Down
7 changes: 6 additions & 1 deletion crates/subspace-farmer/src/single_disk_farm/plotting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub(super) async fn plotting<NC, PG, PosTable>(
erasure_coding: ErasureCoding,
handlers: Arc<Handlers>,
modifying_sector_index: Arc<RwLock<Option<SectorIndex>>>,
target_sector_count: u16,
mut sectors_to_plot: mpsc::Receiver<(SectorIndex, oneshot::Sender<()>)>,
) -> Result<(), PlottingError>
where
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8749269

Please sign in to comment.