summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2019-06-26 08:10:00 -0700
committerAlex Crichton <alex@alexcrichton.com>2019-06-26 08:10:00 -0700
commitd12ad870e1ba71c17e262da5da2670ed015f3184 (patch)
tree68be41827ecaed63956beac085664fc3963a4f97
parent5ba3d18162b23b1b0391c8485ef4e2da9b121837 (diff)
downloadrust-installer-d12ad870e1ba71c17e262da5da2670ed015f3184.tar.gz
Use a multi-threaded xz encoder
-rw-r--r--Cargo.toml1
-rw-r--r--src/tarballer.rs6
2 files changed, 6 insertions, 1 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 33e0091..d62cc58 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,6 +16,7 @@ rayon = "1.0"
tar = "0.4.13"
walkdir = "2"
xz2 = "0.1.4"
+num_cpus = "1"
[dependencies.clap]
features = ["yaml"]
diff --git a/src/tarballer.rs b/src/tarballer.rs
index badac9c..9ff1bd2 100644
--- a/src/tarballer.rs
+++ b/src/tarballer.rs
@@ -48,7 +48,11 @@ impl Tarballer {
let gz = GzEncoder::new(create_new_file(tar_gz)?, flate2::Compression::best());
// Prepare the `.tar.xz` file.
- let xz = XzEncoder::new(create_new_file(tar_xz)?, 6);
+ let stream = xz2::stream::MtStreamBuilder::new()
+ .threads(num_cpus::get() as u32)
+ .preset(6)
+ .encoder()?;
+ let xz = XzEncoder::new_stream(create_new_file(tar_xz)?, stream);
// Write the tar into both encoded files. We write all directories
// first, so files may be directly created. (See rust-lang/rustup.rs#1092.)