Skip to content

Commit bd991d9

Browse files
committed
Auto merge of rust-lang#109888 - Mark-Simulacrum:balanced-compression, r=pietroalbini
Remove optimal xz settings from CI This is a companion PR to rust-lang/promote-release#58, which moves the relevant optimal code to rust-lang/promote-release. As mentioned in the comments of that PR, this is expected to cut CI costs (and time, though predominantly felt on fast builders) and reduce wasted resources due to in-practice single-threaded compression not using the full 8+ vCPU builders we have available. This probably shouldn't land before that PR + a simpleinfra change to enable the recompression of xz artifacts. But if it does land, it's just a matter of a few nightlies with slightly larger artifacts, so not a big deal. r? `@pietroalbini`
2 parents eb48e97 + 0da526b commit bd991d9

File tree

2 files changed

+13
-46
lines changed

2 files changed

+13
-46
lines changed

src/ci/run.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules"
5858
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps"
5959
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-cargo-native-static"
6060
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-units-std=1"
61-
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set dist.compression-profile=best"
61+
# rust-lang/promote-release will recompress CI artifacts, and while we care
62+
# about the per-commit artifact sizes, it's not as important that they're
63+
# highly compressed as it is that the process is fast. Best compression
64+
# generally implies single-threaded compression which results in wasting most
65+
# of our CPU resources.
66+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set dist.compression-profile=balanced"
6267

6368
# When building for mingw, limit the number of parallel linker jobs during
6469
# the LLVM build, as not to run out of memory.

src/tools/rust-installer/src/compression.rs

+7-45
Original file line numberDiff line numberDiff line change
@@ -89,43 +89,11 @@ impl CompressionFormat {
8989
xz2::stream::MtStreamBuilder::new().threads(6).preset(6).encoder().unwrap()
9090
}
9191
CompressionProfile::Best => {
92-
let mut filters = xz2::stream::Filters::new();
93-
// the preset is overridden by the other options so it doesn't matter
94-
let mut lzma_ops = xz2::stream::LzmaOptions::new_preset(9).unwrap();
95-
// This sets the overall dictionary size, which is also how much memory (baseline)
96-
// is needed for decompression.
97-
lzma_ops.dict_size(64 * 1024 * 1024);
98-
// Use the best match finder for compression ratio.
99-
lzma_ops.match_finder(xz2::stream::MatchFinder::BinaryTree4);
100-
lzma_ops.mode(xz2::stream::Mode::Normal);
101-
// Set nice len to the maximum for best compression ratio
102-
lzma_ops.nice_len(273);
103-
// Set depth to a reasonable value, 0 means auto, 1000 is somwhat high but gives
104-
// good results.
105-
lzma_ops.depth(1000);
106-
// 2 is the default and does well for most files
107-
lzma_ops.position_bits(2);
108-
// 0 is the default and does well for most files
109-
lzma_ops.literal_position_bits(0);
110-
// 3 is the default and does well for most files
111-
lzma_ops.literal_context_bits(3);
112-
113-
filters.lzma2(&lzma_ops);
114-
115-
let mut builder = xz2::stream::MtStreamBuilder::new();
116-
builder.filters(filters);
117-
118-
// On 32-bit platforms limit ourselves to 3 threads, otherwise we exceed memory
119-
// usage this process can take. In the future we'll likely only do super-fast
120-
// compression in CI and move this heavyweight processing to promote-release (which
121-
// is always 64-bit and can run on big-memory machines) but for now this lets us
122-
// move forward.
123-
if std::mem::size_of::<usize>() == 4 {
124-
builder.threads(3);
125-
} else {
126-
builder.threads(6);
127-
}
128-
builder.encoder().unwrap()
92+
// Note that this isn't actually the best compression settings for the
93+
// produced artifacts, the production artifacts on static.rust-lang.org are
94+
// produced by rust-lang/promote-release which hosts recompression logic
95+
// and is tuned for optimal compression.
96+
xz2::stream::MtStreamBuilder::new().threads(6).preset(9).encoder().unwrap()
12997
}
13098
};
13199

@@ -245,20 +213,14 @@ impl Write for CombinedEncoder {
245213
}
246214

247215
fn flush(&mut self) -> std::io::Result<()> {
248-
self.encoders
249-
.par_iter_mut()
250-
.map(|w| w.flush())
251-
.collect::<std::io::Result<Vec<()>>>()?;
216+
self.encoders.par_iter_mut().map(|w| w.flush()).collect::<std::io::Result<Vec<()>>>()?;
252217
Ok(())
253218
}
254219
}
255220

256221
impl Encoder for CombinedEncoder {
257222
fn finish(self: Box<Self>) -> Result<(), Error> {
258-
self.encoders
259-
.into_par_iter()
260-
.map(|e| e.finish())
261-
.collect::<Result<Vec<()>, Error>>()?;
223+
self.encoders.into_par_iter().map(|e| e.finish()).collect::<Result<Vec<()>, Error>>()?;
262224
Ok(())
263225
}
264226
}

0 commit comments

Comments
 (0)