From: Matt Corallo Date: Sun, 26 May 2019 18:03:35 +0000 (-0400) Subject: Use more threads to avoid locks blocking all progress X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=dnsseed-rust;a=commitdiff_plain;h=18a1f7614129571ce67d63521e79a0fbf4d7de1b Use more threads to avoid locks blocking all progress --- diff --git a/Cargo.toml b/Cargo.toml index 95bc9b5..fb03cb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ bytes = "0.4" futures = "0.1" rand = "0.6" regex = "1" +num_cpus = "1" [profile.release] lto = true diff --git a/src/main.rs b/src/main.rs index cefbbc1..7495d17 100644 --- a/src/main.rs +++ b/src/main.rs @@ -356,7 +356,11 @@ fn main() { unsafe { HIGHEST_HEADER = Some(Box::new(Mutex::new((genesis_block(Network::Bitcoin).bitcoin_hash(), 0)))) }; unsafe { REQUEST_BLOCK = Some(Box::new(Mutex::new(Arc::new((0, genesis_block(Network::Bitcoin).bitcoin_hash(), genesis_block(Network::Bitcoin)))))) }; - tokio::run(future::lazy(|| { + let trt = tokio::runtime::Builder::new() + .blocking_threads(2).core_threads(num_cpus::get().max(1) * 3) + .build().unwrap(); + + let _ = trt.block_on_all(future::lazy(|| { let mut args = env::args(); args.next(); let path = args.next().unwrap();