mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-19 03:04:27 -05:00
chore: remove reserved_cpu_cores from rayon thread pools (#22221)
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
committed by
GitHub
parent
7594e1513a
commit
9265e8e46c
@@ -85,7 +85,7 @@ use reth_tracing::{
|
||||
};
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
use reth_trie_db::ChangesetCache;
|
||||
use std::{sync::Arc, thread::available_parallelism, time::Duration};
|
||||
use std::{num::NonZeroUsize, sync::Arc, thread::available_parallelism, time::Duration};
|
||||
use tokio::sync::{
|
||||
mpsc::{unbounded_channel, UnboundedSender},
|
||||
oneshot, watch,
|
||||
@@ -228,8 +228,10 @@ impl LaunchContext {
|
||||
}
|
||||
|
||||
// Configure the implicit global rayon pool for `par_iter` usage.
|
||||
let num_threads = available_parallelism()
|
||||
.map_or(0, |num| num.get().saturating_sub(reserved_cpu_cores).max(1));
|
||||
// TODO: reserved_cpu_cores is currently ignored because subtracting from thread pool
|
||||
// sizes doesn't actually reserve CPU cores for other processes.
|
||||
let _ = reserved_cpu_cores;
|
||||
let num_threads = available_parallelism().map_or(1, NonZeroUsize::get);
|
||||
if let Err(err) = ThreadPoolBuilder::new()
|
||||
.num_threads(num_threads)
|
||||
.thread_name(|i| format!("rayon-{i:02}"))
|
||||
|
||||
@@ -18,7 +18,7 @@ use futures_util::{
|
||||
Future, FutureExt, TryFutureExt,
|
||||
};
|
||||
#[cfg(feature = "rayon")]
|
||||
use std::thread::available_parallelism;
|
||||
use std::{num::NonZeroUsize, thread::available_parallelism};
|
||||
use std::{
|
||||
pin::pin,
|
||||
sync::{
|
||||
@@ -183,10 +183,10 @@ impl RayonConfig {
|
||||
|
||||
/// Compute the default number of threads based on available parallelism.
|
||||
fn default_thread_count(&self) -> usize {
|
||||
self.cpu_threads.unwrap_or_else(|| {
|
||||
available_parallelism()
|
||||
.map_or(1, |num| num.get().saturating_sub(self.reserved_cpu_cores).max(1))
|
||||
})
|
||||
// TODO: reserved_cpu_cores is currently ignored because subtracting from thread pool
|
||||
// sizes doesn't actually reserve CPU cores for other processes.
|
||||
let _ = self.reserved_cpu_cores;
|
||||
self.cpu_threads.unwrap_or_else(|| available_parallelism().map_or(1, NonZeroUsize::get))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user