Skip to content
This repository was archived by the owner on Aug 31, 2022. It is now read-only.

Commit 9f6f8ae

Browse files
committed
Revert "Default to number of physical cores on Intel systems"
This reverts commit 2994ded. Lowering the thread priority for CPU miners seems to be a generally better solution.
1 parent 9ab457e commit 9f6f8ae

File tree

3 files changed

+3
-45
lines changed

3 files changed

+3
-45
lines changed

Cargo.lock

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ itertools = "0.8.2"
2929
num_cpus = "1.11.1"
3030
crossbeam = "0.7.3"
3131
ring = "0.16.11"
32-
raw-cpuid = "7.0.3"
3332

3433
[target.'cfg(windows)'.dependencies]
3534
winapi = "0.3.8"

src/miner/cpu/mod.rs

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ use crossbeam::atomic::AtomicCell;
99
use crossbeam::channel::RecvTimeoutError;
1010
use enumset::{EnumSet, EnumSetType};
1111
use itertools::Itertools;
12-
use raw_cpuid::CpuId;
13-
use std::cmp::max;
1412
use std::fmt::{self, Display, Formatter};
1513
use std::num::Wrapping;
1614
use std::str::FromStr;
@@ -71,9 +69,7 @@ impl Display for KernelType {
7169

7270
#[derive(Debug)]
7371
pub 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-
\tCores/threads: {cores}/{threads}\n\
86-
\tDefault miner threads: {miner_threads}\n\
81+
\tThreads: {threads}\n\
8782
\tSupported kernels: {supported}\n\
8883
\tUnsupported 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-
127105
pub 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

141112
pub 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

Comments
 (0)