1use once_cell::sync::Lazy;
2use std::{env, thread};
3use tokio::runtime::{Builder, Runtime};
4use tracing::debug;
5
6pub static TOKIO: Lazy<Runtime> = Lazy::new(|| {
10 debug!(
11 "starting service dbsp io tokio runtime, workers: {}",
12 env::var("TOKIO_WORKER_THREADS")
13 .unwrap_or_else(|_| { thread::available_parallelism().unwrap().get().to_string() })
14 );
15 Builder::new_multi_thread()
16 .thread_name_fn(|| {
17 use std::sync::atomic::{AtomicUsize, Ordering};
18 static ATOMIC_ID: AtomicUsize = AtomicUsize::new(0);
19 let id = ATOMIC_ID.fetch_add(1, Ordering::SeqCst);
20 format!("feldera-tokio-{}", id)
21 })
22 .thread_stack_size(6 * 1024 * 1024)
23 .enable_all()
24 .build()
25 .unwrap()
26});