From 18a1f7614129571ce67d63521e79a0fbf4d7de1b Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 26 May 2019 14:03:35 -0400 Subject: [PATCH] Use more threads to avoid locks blocking all progress --- Cargo.toml | 1 + src/main.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) 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(); -- 2.39.5