diff --git a/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs b/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs index 0cac32dc7b..bea50958d7 100644 --- a/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs +++ b/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs @@ -641,6 +641,12 @@ where NonZeroUsize::new((cpu_cores.cpu_cores().len() / 2).max(1).min(8)).expect("Not zero; qed") }); + info!( + ?plotting_thread_pool_core_indices, + ?replotting_thread_pool_core_indices, + "Preparing plotting thread pools" + ); + let plotting_thread_pool_manager = create_plotting_thread_pool_manager( plotting_thread_pool_core_indices .into_iter() diff --git a/crates/subspace-farmer/src/lib.rs b/crates/subspace-farmer/src/lib.rs index c3571bce6f..60998c618e 100644 --- a/crates/subspace-farmer/src/lib.rs +++ b/crates/subspace-farmer/src/lib.rs @@ -1,5 +1,6 @@ #![feature( array_chunks, + array_windows, assert_matches, const_option, exact_size_is_empty, diff --git a/crates/subspace-farmer/src/utils.rs b/crates/subspace-farmer/src/utils.rs index ec8ff48002..b7654936ad 100644 --- a/crates/subspace-farmer/src/utils.rs +++ b/crates/subspace-farmer/src/utils.rs @@ -15,7 +15,7 @@ use std::num::NonZeroUsize; use std::ops::Deref; use std::pin::{pin, Pin}; use std::task::{Context, Poll}; -use std::{io, thread}; +use std::{fmt, io, thread}; use thread_priority::{set_current_thread_priority, ThreadPriority}; use tokio::runtime::Handle; use tokio::task; @@ -143,7 +143,7 @@ where } /// Abstraction for CPU core set -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct CpuCoreSet { /// CPU cores that belong to this set cores: Vec, @@ -151,6 +151,49 @@ pub struct CpuCoreSet { topology: Option>, } +impl fmt::Debug for CpuCoreSet { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut s = f.debug_struct("CpuCoreSet"); + #[cfg(not(feature = "numa"))] + if self.cores.array_windows::<2>().all(|&[a, b]| a + 1 == b) { + s.field( + "cores", + &format!( + "{}-{}", + self.cores.first().expect("List of cores is not empty; qed"), + self.cores.last().expect("List of cores is not empty; qed") + ), + ); + } else { + s.field( + "cores", + &self + .cores + .iter() + .map(usize::to_string) + .collect::>() + .join(","), + ); + } + #[cfg(feature = "numa")] + { + use hwlocality::cpu::cpuset::CpuSet; + use hwlocality::ffi::PositiveInt; + + s.field( + "cores", + &CpuSet::from_iter( + self.cores.iter().map(|&core| { + PositiveInt::try_from(core).expect("Valid CPU core index; qed") + }), + ), + ); + } + s.finish_non_exhaustive() + } +} + impl CpuCoreSet { /// Regroup CPU core sets to contain at most `target_sets` sets, useful when there are many L3 /// cache groups and not as many farms @@ -197,7 +240,7 @@ impl CpuCoreSet { let cpu_cores = CpuSet::from_iter( self.cores .iter() - .map(|&core| PositiveInt::try_from(core).expect("Valid CPU core")), + .map(|&core| PositiveInt::try_from(core).expect("Valid CPU core index; qed")), ); if let Err(error) =