@@ -9,8 +9,6 @@ use crossbeam::atomic::AtomicCell;
99use crossbeam:: channel:: RecvTimeoutError ;
1010use enumset:: { EnumSet , EnumSetType } ;
1111use itertools:: Itertools ;
12- use raw_cpuid:: CpuId ;
13- use std:: cmp:: max;
1412use std:: fmt:: { self , Display , Formatter } ;
1513use std:: num:: Wrapping ;
1614use std:: str:: FromStr ;
@@ -71,9 +69,7 @@ impl Display for KernelType {
7169
7270#[ derive( Debug ) ]
7371pub struct CpuInfo {
74- cores : usize ,
7572 threads : usize ,
76- default_miner_threads : usize ,
7773 supported : EnumSet < KernelType > ,
7874}
7975
@@ -82,13 +78,10 @@ impl Display for CpuInfo {
8278 write ! (
8379 f,
8480 "CPU:\n \
85- \t Cores/threads: {cores}/{threads}\n \
86- \t Default miner threads: {miner_threads}\n \
81+ \t Threads: {threads}\n \
8782 \t Supported kernels: {supported}\n \
8883 \t Unsupported kernels: {available}",
89- cores = self . cores,
9084 threads = self . threads,
91- miner_threads = self . default_miner_threads,
9285 supported = self . supported. iter( ) . join( ", " ) ,
9386 available = ( !self . supported) . iter( ) . join( ", " ) ,
9487 )
@@ -109,33 +102,11 @@ fn get_best_kernel() -> KernelType {
109102 Iterator :: max ( get_supported_kernels ( ) . iter ( ) ) . unwrap_or_default ( )
110103}
111104
112- /// Some CPUs seem to really struggle when every thread is in use, to the point
113- /// of making the miner entirely unusable. This is particularly prevalent on
114- /// Intel CPUs, presumably due to the impact of spectre mitigations on
115- /// hyperthreading. Thus, we choose a lower default number of threads on Intel
116- /// hardware.
117- fn get_best_thread_count ( ) -> usize {
118- let cores = num_cpus:: get_physical ( ) ;
119- let threads = num_cpus:: get ( ) ;
120-
121- match CpuId :: new ( ) . get_vendor_info ( ) {
122- Some ( v) if v. as_string ( ) . to_lowercase ( ) . contains ( "intel" ) => max ( threads - 2 , cores) ,
123- _ => threads,
124- }
125- }
126-
127105pub fn get_cpu_info ( ) -> CpuInfo {
128- let cores = num_cpus:: get_physical ( ) ;
129106 let threads = num_cpus:: get ( ) ;
130- let default_miner_threads = get_best_thread_count ( ) ;
131107 let supported = get_supported_kernels ( ) ;
132108
133- CpuInfo {
134- cores,
135- threads,
136- default_miner_threads,
137- supported,
138- }
109+ CpuInfo { threads, supported }
139110}
140111
141112pub struct CpuMiner {
@@ -152,7 +123,7 @@ impl CpuMiner {
152123 } : & MinerConfig ,
153124 ) -> CpuMiner {
154125 CpuMiner {
155- threads : cpu_threads. unwrap_or_else ( get_best_thread_count ) ,
126+ threads : cpu_threads. unwrap_or_else ( num_cpus :: get ) ,
156127 kernel_type : cpu_kernel. unwrap_or_else ( get_best_kernel) ,
157128 }
158129 }
0 commit comments