@@ -35,7 +35,7 @@ use subspace_farmer::utils::ss58::parse_ss58_reward_address;
35
35
use subspace_farmer:: utils:: {
36
36
all_cpu_cores, create_plotting_thread_pool_manager, parse_cpu_cores_sets,
37
37
recommended_number_of_farming_threads, run_future_in_dedicated_thread,
38
- thread_pool_core_indices, AsyncJoinOnDrop ,
38
+ thread_pool_core_indices, AsyncJoinOnDrop , CpuCoreSet ,
39
39
} ;
40
40
use subspace_farmer:: { Identity , NodeClient , NodeRpcClient } ;
41
41
use subspace_farmer_components:: plotting:: PlottedSector ;
@@ -132,7 +132,8 @@ pub(crate) struct FarmingArgs {
132
132
farm_during_initial_plotting : bool ,
133
133
/// Size of PER FARM thread pool used for farming (mostly for blocking I/O, but also for some
134
134
/// compute-intensive operations during proving), defaults to number of logical CPUs
135
- /// available on UMA system and number of logical CPUs in first NUMA node on NUMA system
135
+ /// available on UMA system and number of logical CPUs in first NUMA node on NUMA system, but
136
+ /// not more than 32 threads
136
137
#[ arg( long) ]
137
138
farming_thread_pool_size : Option < NonZeroUsize > ,
138
139
/// Size of one thread pool used for plotting, defaults to number of logical CPUs available
@@ -469,8 +470,8 @@ where
469
470
None => farmer_app_info. protocol_info . max_pieces_in_sector ,
470
471
} ;
471
472
472
- let plotting_thread_pool_core_indices;
473
- let replotting_thread_pool_core_indices;
473
+ let mut plotting_thread_pool_core_indices;
474
+ let mut replotting_thread_pool_core_indices;
474
475
if let Some ( plotting_cpu_cores) = plotting_cpu_cores {
475
476
plotting_thread_pool_core_indices = parse_cpu_cores_sets ( & plotting_cpu_cores)
476
477
. map_err ( |error| anyhow:: anyhow!( "Failed to parse `--plotting-cpu-cores`: {error}" ) ) ?;
@@ -503,6 +504,25 @@ where
503
504
}
504
505
replotting_thread_pool_core_indices
505
506
} ;
507
+
508
+ if plotting_thread_pool_core_indices. len ( ) > 1 {
509
+ info ! (
510
+ l3_cache_groups = %plotting_thread_pool_core_indices. len( ) ,
511
+ "Multiple L3 cache groups detected"
512
+ ) ;
513
+
514
+ if plotting_thread_pool_core_indices. len ( ) > disk_farms. len ( ) {
515
+ plotting_thread_pool_core_indices =
516
+ CpuCoreSet :: regroup ( & plotting_thread_pool_core_indices, disk_farms. len ( ) ) ;
517
+ replotting_thread_pool_core_indices =
518
+ CpuCoreSet :: regroup ( & replotting_thread_pool_core_indices, disk_farms. len ( ) ) ;
519
+
520
+ info ! (
521
+ farms_count = %disk_farms. len( ) ,
522
+ "Regrouped CPU cores to match number of farms, more farms may leverage CPU more efficiently"
523
+ ) ;
524
+ }
525
+ }
506
526
}
507
527
508
528
let downloading_semaphore = Arc :: new ( Semaphore :: new (
@@ -520,30 +540,6 @@ where
520
540
. map ( |farming_thread_pool_size| farming_thread_pool_size. get ( ) )
521
541
. unwrap_or_else ( recommended_number_of_farming_threads) ;
522
542
523
- let all_cpu_cores = all_cpu_cores ( ) ;
524
- if all_cpu_cores. len ( ) > 1 {
525
- info ! ( l3_cache_groups = %all_cpu_cores. len( ) , "Multiple L3 cache groups detected" ) ;
526
-
527
- if all_cpu_cores. len ( ) > disk_farms. len ( ) {
528
- warn ! (
529
- l3_cache_groups = %all_cpu_cores. len( ) ,
530
- farms_count = %disk_farms. len( ) ,
531
- "Too few disk farms, CPU will not be utilized fully during plotting, same number \
532
- of farms as L3 cache groups or more is recommended"
533
- ) ;
534
- }
535
- }
536
-
537
- // TODO: Remove code or environment variable once identified whether it helps or not
538
- if std:: env:: var ( "NUMA_ALLOCATOR" ) . is_ok ( ) && all_cpu_cores. len ( ) > 1 {
539
- unsafe {
540
- libmimalloc_sys:: mi_option_set (
541
- libmimalloc_sys:: mi_option_use_numa_nodes,
542
- all_cpu_cores. len ( ) as std:: ffi:: c_long ,
543
- ) ;
544
- }
545
- }
546
-
547
543
let mut plotting_delay_senders = Vec :: with_capacity ( disk_farms. len ( ) ) ;
548
544
549
545
for ( disk_farm_index, disk_farm) in disk_farms. into_iter ( ) . enumerate ( ) {
0 commit comments