Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use at most 8 threads for the xz stream #98

Merged
merged 1 commit into from
Aug 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/tarballer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down