From 37222683ee11c343764512babc676c5dbccdb446 Mon Sep 17 00:00:00 2001 From: sakridge Date: Tue, 6 Oct 2020 17:17:26 -0700 Subject: [PATCH] Add env variable for rayon thread counts (#12693) --- rayon-threadlimit/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rayon-threadlimit/src/lib.rs b/rayon-threadlimit/src/lib.rs index 5580f21726..16605b9351 100644 --- a/rayon-threadlimit/src/lib.rs +++ b/rayon-threadlimit/src/lib.rs @@ -1,12 +1,16 @@ #[macro_use] extern crate lazy_static; +use std::env; //TODO remove this hack when rayon fixes itself 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 = num_cpus::get() as usize / 2; + 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); } pub fn get_thread_count() -> usize {