Skip to content

Commit

Permalink
Take .max(1) when computing MAX_RAYON_THREADS (#25940)
Browse files Browse the repository at this point in the history
(cherry picked from commit c419845)
  • Loading branch information
brooksprumo authored and mergify[bot] committed Aug 7, 2022
1 parent 3ebadb8 commit 0446c0c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions rayon-threadlimit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ lazy_static! {
// reduce the number of threads each pool is allowed to half the cpu core count, to avoid rayon
// hogging cpu
static ref MAX_RAYON_THREADS: usize =
env::var("SOLANA_RAYON_THREADS")
.map(|x| x.parse().unwrap_or(num_cpus::get() as usize / 2))
.unwrap_or(num_cpus::get() as usize / 2);
env::var("SOLANA_RAYON_THREADS").ok()
.and_then(|num_threads| num_threads.parse().ok())
.unwrap_or_else(|| num_cpus::get() as usize / 2)
.max(1);
}

pub fn get_thread_count() -> usize {
Expand Down

0 comments on commit 0446c0c

Please sign in to comment.