rt: set worker thread count

use at least 2 but at most 4 worker threads

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2022-06-21 10:09:53 +02:00
parent b8cb8723bd
commit 53d40ceeab
2 changed files with 9 additions and 2 deletions

View File

@ -12,9 +12,10 @@ homepage = "https://www.proxmox.com"
exclude = [ "build", "debian" ]
[dependencies]
bitflags = "1.2"
anyhow = "1.0"
bitflags = "1.2"
lazy_static = "1.4"
libc = "0.2"
nix = "0.24"
num_cpus = "1"
tokio = { version = "1.0", features = [ "rt-multi-thread", "io-util", "net" ] }

View File

@ -101,7 +101,13 @@ fn main() {
}
};
let rt = tokio::runtime::Runtime::new().expect("failed to spawn tokio runtime");
let cpus = num_cpus::get();
let rt = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.worker_threads(cpus.max(2).min(4))
.build()
.expect("failed to spawn tokio runtime");
if let Err(err) = rt.block_on(do_main(use_sd_notify, path)) {
eprintln!("error: {}", err);