Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(core): default tokio worker threads to std::thread::available_parallelism() #18541

Merged
merged 5 commits into from
Sep 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,20 +467,16 @@ pub fn build_runtime(threads: Option<usize>, thread_name: &str) -> Result<Runtim
rt_builder.max_blocking_threads(20_000);
rt_builder.enable_all().thread_name(thread_name);

if let Some(threads) = threads {
if threads < 1 {
#[allow(clippy::print_stderr)]
{
eprintln!("The `threads` argument must be greater or equal to 1.");
}
return Err(exitcode::CONFIG);
} else {
WORKER_THREADS
.set(NonZeroUsize::new(threads).expect("already checked"))
.expect("double thread initialization");
rt_builder.worker_threads(threads);
}
let threads = threads.unwrap_or_else(crate::num_threads);
if threads < 1 {
error!("The `threads` argument must be greater or equal to 1.");
return Err(exitcode::CONFIG);
}
WORKER_THREADS
.set(NonZeroUsize::new(threads).expect("already checked"))
.expect("double thread initialization");
rt_builder.worker_threads(threads);
info!("tokio runtime created with {threads} worker threads");
dsmith3197 marked this conversation as resolved.
Show resolved Hide resolved

Ok(rt_builder.build().expect("Unable to create async runtime"))
}
Expand Down
Loading