mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
Use 3 or 6 compression threads for rust-installer
Limit to 3 threads for 32-bit platforms, otherwise we use 6 threads. This avoids exceeding the amount of memory we can allocate on a 32-bit platform.
This commit is contained in:
parent
ddc2d1e806
commit
dabafb44e0
@ -61,13 +61,24 @@ impl CompressionFormat {
|
||||
lzma_ops.literal_context_bits(3);
|
||||
|
||||
filters.lzma2(&lzma_ops);
|
||||
|
||||
let mut builder = xz2::stream::MtStreamBuilder::new();
|
||||
builder.filters(filters);
|
||||
|
||||
// On 32-bit platforms limit ourselves to 3 threads, otherwise we exceed memory
|
||||
// usage this process can take. In the future we'll likely only do super-fast
|
||||
// compression in CI and move this heavyweight processing to promote-release (which
|
||||
// is always 64-bit and can run on big-memory machines) but for now this lets us
|
||||
// move forward.
|
||||
if std::mem::size_of::<usize>() == 4 {
|
||||
builder.threads(3);
|
||||
} else {
|
||||
builder.threads(6);
|
||||
}
|
||||
|
||||
let compressor = XzEncoder::new_stream(
|
||||
std::io::BufWriter::new(file),
|
||||
xz2::stream::MtStreamBuilder::new()
|
||||
.threads(1)
|
||||
.filters(filters)
|
||||
.encoder()
|
||||
.unwrap(),
|
||||
builder.encoder().unwrap(),
|
||||
);
|
||||
Box::new(compressor)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user