Limit Rayon threadpool threads (#5871)
This commit is contained in:
@ -75,6 +75,7 @@ tokio-codec = "0.1"
|
||||
tokio-fs = "0.1"
|
||||
tokio-io = "0.1"
|
||||
untrusted = "0.7.0"
|
||||
solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "0.19.0-pre0" }
|
||||
|
||||
# reed-solomon-erasure's simd_c feature fails to build for x86_64-pc-windows-msvc, use pure-rust
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
|
@ -2,6 +2,8 @@ use crate::bank_forks::BankForks;
|
||||
use crate::blocktree::{Blocktree, SlotMeta};
|
||||
use crate::entry::{Entry, EntrySlice};
|
||||
use crate::leader_schedule_cache::LeaderScheduleCache;
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::thread_rng;
|
||||
use rayon::prelude::*;
|
||||
use rayon::ThreadPool;
|
||||
use solana_metrics::{datapoint, datapoint_error, inc_new_counter_debug};
|
||||
@ -16,16 +18,15 @@ use std::result;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::thread_rng;
|
||||
|
||||
pub const NUM_THREADS: u32 = 10;
|
||||
use solana_rayon_threadlimit::get_thread_count;
|
||||
use std::cell::RefCell;
|
||||
|
||||
thread_local!(static PAR_THREAD_POOL: RefCell<ThreadPool> = RefCell::new(rayon::ThreadPoolBuilder::new()
|
||||
.num_threads(sys_info::cpu_num().unwrap_or(NUM_THREADS) as usize)
|
||||
.num_threads(get_thread_count())
|
||||
.build()
|
||||
.unwrap()));
|
||||
.unwrap())
|
||||
);
|
||||
|
||||
fn first_err(results: &[Result<()>]) -> Result<()> {
|
||||
for r in results {
|
||||
|
@ -14,6 +14,7 @@ use solana_merkle_tree::MerkleTree;
|
||||
use solana_metrics::inc_new_counter_warn;
|
||||
use solana_sdk::hash::Hash;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::timing;
|
||||
use solana_sdk::transaction::Transaction;
|
||||
use std::borrow::Borrow;
|
||||
use std::cell::RefCell;
|
||||
@ -22,7 +23,7 @@ use std::sync::{Arc, RwLock};
|
||||
|
||||
#[cfg(feature = "cuda")]
|
||||
use crate::sigverify::poh_verify_many;
|
||||
use solana_sdk::timing;
|
||||
use solana_rayon_threadlimit::get_thread_count;
|
||||
#[cfg(feature = "cuda")]
|
||||
use std::sync::Mutex;
|
||||
#[cfg(feature = "cuda")]
|
||||
@ -32,7 +33,7 @@ use std::time::Instant;
|
||||
pub const NUM_THREADS: u32 = 10;
|
||||
|
||||
thread_local!(static PAR_THREAD_POOL: RefCell<ThreadPool> = RefCell::new(rayon::ThreadPoolBuilder::new()
|
||||
.num_threads(sys_info::cpu_num().unwrap_or(NUM_THREADS) as usize)
|
||||
.num_threads(get_thread_count())
|
||||
.build()
|
||||
.unwrap()));
|
||||
|
||||
|
@ -19,17 +19,16 @@ use solana_sdk::signature::Signature;
|
||||
use solana_sdk::transaction::Transaction;
|
||||
use std::mem::size_of;
|
||||
|
||||
#[cfg(feature = "cuda")]
|
||||
use std::os::raw::{c_int, c_uint};
|
||||
|
||||
#[cfg(feature = "cuda")]
|
||||
use core::ffi::c_void;
|
||||
|
||||
use solana_rayon_threadlimit::get_thread_count;
|
||||
#[cfg(feature = "cuda")]
|
||||
use std::os::raw::{c_int, c_uint};
|
||||
pub const NUM_THREADS: u32 = 10;
|
||||
use std::cell::RefCell;
|
||||
|
||||
thread_local!(static PAR_THREAD_POOL: RefCell<ThreadPool> = RefCell::new(rayon::ThreadPoolBuilder::new()
|
||||
.num_threads(sys_info::cpu_num().unwrap_or(NUM_THREADS) as usize)
|
||||
.num_threads(get_thread_count())
|
||||
.build()
|
||||
.unwrap()));
|
||||
|
||||
|
@ -12,6 +12,7 @@ use crate::streamer::{PacketReceiver, PacketSender};
|
||||
use rayon::iter::{IndexedParallelIterator, IntoParallelRefMutIterator, ParallelIterator};
|
||||
use rayon::ThreadPool;
|
||||
use solana_metrics::{inc_new_counter_debug, inc_new_counter_error};
|
||||
use solana_rayon_threadlimit::get_thread_count;
|
||||
use solana_runtime::bank::Bank;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::timing::duration_as_ms;
|
||||
@ -205,7 +206,7 @@ impl WindowService {
|
||||
trace!("{}: RECV_WINDOW started", id);
|
||||
let mut now = Instant::now();
|
||||
let thread_pool = rayon::ThreadPoolBuilder::new()
|
||||
.num_threads(sys_info::cpu_num().unwrap_or(NUM_THREADS) as usize)
|
||||
.num_threads(get_thread_count())
|
||||
.build()
|
||||
.unwrap();
|
||||
loop {
|
||||
|
Reference in New Issue
Block a user