perf: increase threads in global pool (#11075)

This commit is contained in:
Federico Gimenez
2024-09-20 19:56:46 +02:00
committed by GitHub
parent 5e1b49429f
commit 3416145574

View File

@ -180,10 +180,10 @@ impl LaunchContext {
Err(err) => warn!(%err, "Failed to raise file descriptor limit"),
}
// Limit the global rayon thread pool, reserving 2 cores for the rest of the system.
// If the system has less than 2 cores, it will use 1 core.
// Limit the global rayon thread pool, reserving 1 core for the rest of the system.
// If the system only has 1 core the pool will use it.
let num_threads =
available_parallelism().map_or(0, |num| num.get().saturating_sub(2).max(1));
available_parallelism().map_or(0, |num| num.get().saturating_sub(1).max(1));
if let Err(err) = ThreadPoolBuilder::new()
.num_threads(num_threads)
.thread_name(|i| format!("reth-rayon-{i}"))