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

Print CPU cores used for plotting and replotting thread pools during start of the farmer #2662

Merged
merged 1 commit into from
Apr 4, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions crates/subspace-farmer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![feature(
array_chunks,
array_windows,
assert_matches,
const_option,
exact_size_is_empty,
Expand Down
49 changes: 46 additions & 3 deletions crates/subspace-farmer/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -143,14 +143,57 @@ where
}

/// Abstraction for CPU core set
#[derive(Debug, Clone)]
#[derive(Clone)]
pub struct CpuCoreSet {
/// CPU cores that belong to this set
cores: Vec<usize>,
#[cfg(feature = "numa")]
topology: Option<std::sync::Arc<hwlocality::Topology>>,
}

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::<Vec<_>>()
.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
Expand Down Expand Up @@ -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) =
Expand Down
Loading