Take `.max(1)` when computing MAX_RAYON_THREADS (#25940)
This commit is contained in:
parent
d56a706b20
commit
c419845cfe
|
@ -8,9 +8,10 @@ lazy_static! {
|
||||||
// reduce the number of threads each pool is allowed to half the cpu core count, to avoid rayon
|
// reduce the number of threads each pool is allowed to half the cpu core count, to avoid rayon
|
||||||
// hogging cpu
|
// hogging cpu
|
||||||
static ref MAX_RAYON_THREADS: usize =
|
static ref MAX_RAYON_THREADS: usize =
|
||||||
env::var("SOLANA_RAYON_THREADS")
|
env::var("SOLANA_RAYON_THREADS").ok()
|
||||||
.map(|x| x.parse().unwrap_or(num_cpus::get() as usize / 2))
|
.and_then(|num_threads| num_threads.parse().ok())
|
||||||
.unwrap_or(num_cpus::get() as usize / 2);
|
.unwrap_or_else(|| num_cpus::get() as usize / 2)
|
||||||
|
.max(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_thread_count() -> usize {
|
pub fn get_thread_count() -> usize {
|
||||||
|
|
Loading…
Reference in New Issue