[elbe-devel] [PATCH 3/5] elbepack: parallelize xz invocations
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Tue Mar 5 16:11:57 CET 2024
The compression steps take a long time single-threaded.
As xz can already parallelize operations make use of that functionality
to speed up the build.
With the 1GiB of RAM in the default initvm xz can use 4 threads for
compression.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/elbeproject.py | 10 +++++++---
elbepack/packers.py | 2 +-
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
index 8a2bc6a32c95..b54971786205 100644
--- a/elbepack/elbeproject.py
+++ b/elbepack/elbeproject.py
@@ -201,7 +201,8 @@ class ElbeProject:
self.host_sysrootenv = None
def build_chroottarball(self):
- do(f'tar cJf {self.builddir}/chroot.tar.xz '
+ do('XZ_OPT="-T0 -M80%" '
+ f'tar cJf {self.builddir}/chroot.tar.xz '
'--exclude=./tmp/* --exclude=./dev/* '
'--exclude=./run/* --exclude=./sys/* '
'--exclude=./proc/* --exclude=./var/cache/* '
@@ -303,6 +304,7 @@ class ElbeProject:
filelist_fd.write('./sbin\n')
do(
+ 'XZ_OPT="-T0 -M80%" '
f'tar cfJ {self.builddir}/sysroot.tar.xz '
f'-C {self.sysrootpath} -T {sysrootfilelist}')
@@ -385,7 +387,9 @@ class ElbeProject:
self.build_sysroot()
sdktargetpath = os.path.join(self.sdkpath, 'sysroots', 'target')
do(f'mkdir -p {sdktargetpath}')
- do(f'tar xJf {self.builddir}/sysroot.tar.xz -C {sdktargetpath}')
+ do(
+ 'XZ_OPT="-T0 -M80%" '
+ f'tar xJf {self.builddir}/sysroot.tar.xz -C {sdktargetpath}')
# build host sysroot including cross compiler
hostsysrootpath = os.path.join(self.sdkpath, 'sysroots', 'host')
@@ -399,7 +403,7 @@ class ElbeProject:
self.sdkpath)
# create sdk tar and append it to setup script
- do(f'cd {self.sdkpath}; tar cJf ../sdk.txz .')
+ do(f'cd {self.sdkpath}; XZ_OPT="-T0 -M80%" tar cJf ../sdk.txz .')
do(f'cd {self.builddir}; rm -rf sdk')
do(f'cd {self.builddir}; cat sdk.txz >> {n}')
do(f'cd {self.builddir}; chmod +x {n}')
diff --git a/elbepack/packers.py b/elbepack/packers.py
index 7a3a929d4566..308074bb52bf 100644
--- a/elbepack/packers.py
+++ b/elbepack/packers.py
@@ -72,7 +72,7 @@ packers = {'none': NoPacker(),
'gzip': InPlacePacker('gzip -f', '.gz'),
'zstd': InPlacePacker('zstd -T0', '.zst'),
'tar': TarArchiver('--auto-compress', '.tar'),
- 'tarxz': TarArchiver('--auto-compress', '.tar.xz'),
+ 'tarxz': TarArchiver('--use-compress-program="xz -T0 -M80%"', '.tar.xz'),
'targz': TarArchiver('--auto-compress', '.tar.gz'),
'tarzstd': TarArchiver('--use-compress-program="zstd -T0"', '.tar.zst'),
}
--
2.44.0
More information about the elbe-devel
mailing list