summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2019-08-28 16:43:17 -0500
committerGitHub <noreply@github.com>2019-08-28 16:43:17 -0500
commit9f66c14c3f91a48a118c7817f434167b311c3515 (patch)
tree8d375f8ec9e9b860a155e32c303419088411a900
parent85958b001dbff8523396809bfa844fc34a7869a8 (diff)
parent3d7273c36f801fb0da8ae70eec7fe742c317df45 (diff)
downloadrust-installer-9f66c14c3f91a48a118c7817f434167b311c3515.tar.gz
Merge pull request #98 from cuviper/xz-thread-mem
Use at most 8 threads for the xz stream
-rw-r--r--src/tarballer.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/tarballer.rs b/src/tarballer.rs
index 9ff1bd2..fa6ab2c 100644
--- a/src/tarballer.rs
+++ b/src/tarballer.rs
@@ -47,9 +47,11 @@ impl Tarballer {
// Prepare the `.tar.gz` file.
let gz = GzEncoder::new(create_new_file(tar_gz)?, flate2::Compression::best());
- // Prepare the `.tar.xz` file.
+ // Prepare the `.tar.xz` file. Note that preset 6 takes about 173MB of memory
+ // per thread, so we limit the number of threads to not blow out 32-bit hosts.
+ // (We could be more precise with `MtStreamBuilder::memusage()` if desired.)
let stream = xz2::stream::MtStreamBuilder::new()
- .threads(num_cpus::get() as u32)
+ .threads(Ord::min(num_cpus::get(), 8) as u32)
.preset(6)
.encoder()?;
let xz = XzEncoder::new_stream(create_new_file(tar_xz)?, stream);