summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-bsp/fwupd/fwupd/0001-fu-lzma-common.c-reduce-lzma-compression-level-from-.patch
blob: b0d3863eaa2eb9a56577433bc9201bab5e0a5737 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From c96668ab830d016eeff977d5ca4f99d288cf38c0 Mon Sep 17 00:00:00 2001
From: Mikko Rapeli <mikko.rapeli@linaro.org>
Date: Tue, 8 Jul 2025 07:05:02 +0000
Subject: [PATCH] fu-lzma-common.c: reduce lzma compression level from 9 to
 default 6

xz manual page says default is 6 and levels higher than that can cause
huge CPU and memory usage. On yocto qemu target, the fwupd tests
fail to run with compression level 9:

FuSelfTest:ERROR:../sources/fwupd-2.0.12/libfwupdplugin/fu-self-test.c:6342:fu_lzma_func: assertion failed (error == NULL): failed to set up LZMA encoder rc=5 (FwupdError, 10)
not ok /fwupd/lzma - FuSelfTest:ERROR:../sources/fwupd-2.0.12/libfwupdplugin/fu-self-test.c:6342:fu_lzma_func: assertion failed (error == NULL): failed to set up LZMA encoder rc=5 (FwupdError, 10)

With default compression level 6 the tests pass.

https://linux.die.net/man/1/xz

 -6 ... -9
    Excellent compression with medium to high memory usage.
    These are also slower than the lower preset levels.
    The default is -6. Unless you want to maximize the compression ratio,
    you probably don't want a higher preset level than -7 due to
    speed and memory usage.

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
---
 libfwupdplugin/fu-lzma-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Upstream-Status: Submitted [https://github.com/fwupd/fwupd/pull/9019]

diff --git a/libfwupdplugin/fu-lzma-common.c b/libfwupdplugin/fu-lzma-common.c
index a64ec773da91..d381ed52e135 100644
--- a/libfwupdplugin/fu-lzma-common.c
+++ b/libfwupdplugin/fu-lzma-common.c
@@ -89,7 +89,7 @@ fu_lzma_compress_bytes(GBytes *blob, GError **error)
 	strm.next_in = g_bytes_get_data(blob, NULL);
 	strm.avail_in = g_bytes_get_size(blob);
 
-	rc = lzma_easy_encoder(&strm, 9, LZMA_CHECK_CRC64);
+	rc = lzma_easy_encoder(&strm, 6, LZMA_CHECK_CRC64);
 	if (rc != LZMA_OK) {
 		lzma_end(&strm);
 		g_set_error(error,
-- 
2.43.0