solana/rayon-threadlimit/src/lib.rs

15 lines
373 B
Rust
Raw Normal View History

2019-09-12 11:39:39 -07:00
#[macro_use]
extern crate lazy_static;
//TODO remove this hack when rayon fixes itself
2019-09-12 11:39:39 -07:00
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 = sys_info::cpu_num().unwrap() as usize / 2;
2019-09-12 11:39:39 -07:00
}
pub fn get_thread_count() -> usize {
*MAX_RAYON_THREADS
2019-09-12 11:39:39 -07:00
}