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

Changing the default number of threads for the main tokio runtime. #5124

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Changes from all commits
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
10 changes: 10 additions & 0 deletions quickwit/quickwit-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,21 @@ use quickwit_common::runtimes::scrape_tokio_runtime_metrics;
use quickwit_serve::BuildInfo;
use tracing::error;

/// The main tokio runtime takes num_cores / 3 threads by default, and can be overridden by the
/// QW_RUNTIME_NUM_THREADS environment variable.
fn get_main_runtime_num_threads() -> usize {
let default_num_runtime_threads: usize = quickwit_common::num_cpus().div_ceil(3);
quickwit_common::get_from_env("QW_RUNTIME_NUM_THREADS", default_num_runtime_threads)
}

fn main() -> anyhow::Result<()> {
let main_runtime_num_threads: usize = get_main_runtime_num_threads();
let rt = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.on_thread_unpark(busy_detector::thread_unpark)
.on_thread_park(busy_detector::thread_park)
.thread_name("main_runtime_thread")
.worker_threads(main_runtime_num_threads)
.build()
.context("failed to start main Tokio runtime")?;

Expand Down
Loading