From a19666d884768a3350dd70b8689da3b87e1d17b0 Mon Sep 17 00:00:00 2001 From: Michael Jauregui Date: Sun, 23 Aug 2026 17:56:45 +0200 Subject: [PATCH] magiskboot: Lower the compression presets for XZ & LZMA magiskboot: Lower the compression presets for XZ & LZMA The compression routine always uses the maximum compression preset for all formats. This is problematic with XZ and LZMA because they use far more memory than the other formats, while just providing a very marginal advantage in the resulting file size. The compression preset was changed from 9 to 6, which is often the default value and provides more than enough compression. Tested on Samsung Galaxy Fame (512MB RAM, perfect for this). --- native/src/boot/compress.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/native/src/boot/compress.rs b/native/src/boot/compress.rs index 483d177b4..cb2cc50f8 100644 --- a/native/src/boot/compress.rs +++ b/native/src/boot/compress.rs @@ -222,13 +222,13 @@ pub fn get_encoder<'a, W: Write + 'a>( ) -> std::io::Result + 'a>> { Ok(match format { FileFormat::XZ => { - let mut opt = XzOptions::with_preset(9); + let mut opt = XzOptions::with_preset(6); opt.set_check_sum_type(CheckType::Crc32); Box::new(XzWriter::new(w, opt)?) } FileFormat::LZMA => Box::new(LzmaWriter::new_use_header( w, - &LzmaOptions::with_preset(9), + &LzmaOptions::with_preset(6), None, )?), FileFormat::BZIP2 => Box::new(BzEncoder::new(w, BzCompression::best())),