Skip to content

Commit

Permalink
Limit default number of farming threads
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Jan 30, 2024
1 parent 460cb01 commit 63e0c59
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ use tracing::{debug, error, info, info_span, warn};
use zeroize::Zeroizing;

const RECORDS_ROOTS_CACHE_SIZE: NonZeroUsize = NonZeroUsize::new(1_000_000).expect("Not zero; qed");
/// It doesn't make a lot of sense to have a huge number of farming threads, 32 is plenty
const MAX_DEFAULT_FARMING_THREADS: usize = 32;

fn should_farm_during_initial_plotting() -> bool {
let total_cpu_cores = all_cpu_cores()
Expand Down Expand Up @@ -128,7 +130,8 @@ pub(crate) struct FarmingArgs {
farm_during_initial_plotting: bool,
/// Size of PER FARM thread pool used for farming (mostly for blocking I/O, but also for some
/// compute-intensive operations during proving), defaults to number of logical CPUs
/// available on UMA system and number of logical CPUs in first NUMA node on NUMA system
/// available on UMA system and number of logical CPUs in first NUMA node on NUMA system, but
/// not more than 32 threads
#[arg(long)]
farming_thread_pool_size: Option<NonZeroUsize>,
/// Size of one thread pool used for plotting, defaults to number of logical CPUs available
Expand Down Expand Up @@ -507,7 +510,11 @@ where
.zip(replotting_thread_pool_core_indices),
)?;
let farming_thread_pool_size = farming_thread_pool_size
.map(|farming_thread_pool_size| farming_thread_pool_size.get())
.map(|farming_thread_pool_size| {
farming_thread_pool_size
.get()
.min(MAX_DEFAULT_FARMING_THREADS)
})
.unwrap_or_else(recommended_number_of_farming_threads);

let all_cpu_cores = all_cpu_cores();
Expand Down

0 comments on commit 63e0c59

Please sign in to comment.