[RFC PATCH] rpm: limit xz threading
From: Ross Burton <hidden>
Date: 2021-05-26 14:30:25
Subsystem:
the rest · Maintainer:
Linus Torvalds
Signed-off-by: Ross Burton <redacted> --- .../rpm/files/less-threads.patch | 24 +++++++++++++++++++ meta/recipes-devtools/rpm/rpm_4.16.1.3.bb | 1 + 2 files changed, 25 insertions(+) create mode 100644 meta/recipes-devtools/rpm/files/less-threads.patch
diff --git a/meta/recipes-devtools/rpm/files/less-threads.patch b/meta/recipes-devtools/rpm/files/less-threads.patch
new file mode 100644
index 0000000000..d6db85f28a
--- /dev/null
+++ b/meta/recipes-devtools/rpm/files/less-threads.patch@@ -0,0 +1,24 @@ +Instead of telling XZ to use as many threads as there are processor cores, just +hardcode this to 4. + +On large systems with lots of cores, XZ will use unreasonable amounts of memory. +For example, my ThunderX2 reports 256 cores and rpmbuild takes 3.8GB of resident +memory when packaging cmake. Limiting RPM to just 8 threads reduces this to +1.2GB without massively reducing the compression speed. + +Upstream-Status: Inappropriate +Signed-off-by: Ross Burton <ross.burton@arm.com> + +diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c +index 52be6a38d..c4034e9e5 100644 +--- a/rpmio/rpmio.c ++++ b/rpmio/rpmio.c +@@ -799,7 +799,7 @@ static LZFILE *lzopen_internal(const char *mode, int fd, int xz) + #ifdef HAVE_LZMA_MT + } else { + if (threads == -1) +- threads = rpmExpandNumeric("%{getncpus}"); ++ threads = 8; + lzma_mt mt_options = { + .flags = 0, + .threads = threads,
diff --git a/meta/recipes-devtools/rpm/rpm_4.16.1.3.bb b/meta/recipes-devtools/rpm/rpm_4.16.1.3.bb
index 95a6f5cf71..f7e9378061 100644
--- a/meta/recipes-devtools/rpm/rpm_4.16.1.3.bb
+++ b/meta/recipes-devtools/rpm/rpm_4.16.1.3.bb@@ -40,6 +40,7 @@ SRC_URI = "git://github.com/rpm-software-management/rpm;branch=rpm-4.16.x \ file://0016-rpmscript.c-change-logging-level-around-scriptlets-t.patch \ file://0001-lib-transaction.c-fix-file-conflicts-for-MIPS64-N32.patch \ file://0001-tools-Add-error.h-for-non-glibc-case.patch \ + file://less-threads.patch \ " PE = "1"
--
2.25.1