From e03d61574db5ec8aa1bd593ba7c1d9fabf691312 Mon Sep 17 00:00:00 2001 From: trivernis Date: Sun, 15 Mar 2020 17:57:55 +0100 Subject: [PATCH] Change to only use half the decompression threads --- Cargo.toml | 2 +- src/io.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bb5afc7..ead6ed1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bdflib" -version = "0.4.1" +version = "0.4.2" authors = ["trivernis "] edition = "2018" license-file = "LICENSE" diff --git a/src/io.rs b/src/io.rs index eb428f9..38222bb 100644 --- a/src/io.rs +++ b/src/io.rs @@ -247,7 +247,7 @@ impl BDFReader { /// Starts threads for decompressing chunks fn start_threads(&mut self) { - for _ in 0..num_cpus::get() { + for _ in 0..num_cpus::get()/2 { thread::spawn({ let r = self.thread_manager.receiver_work.clone(); let s = self.thread_manager.sender_result.clone(); @@ -260,6 +260,10 @@ impl BDFReader { drop(wg); } }); + } + // add some initial data to be decompressed. + // the data that is added is four times the number of threads + for _ in 0..num_cpus::get() * 2 { if let Err(_) = self.add_compression_chunk() { self.thread_manager.drop_sender(); break;