]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Run 'xz' and 'lzma' with multiple threads
authorVratislav Podzimek <vpodzime@redhat.com>
Wed, 13 Nov 2013 12:20:39 +0000 (13:20 +0100)
committerHarald Hoyer <harald@redhat.com>
Wed, 13 Nov 2013 12:20:39 +0000 (13:20 +0100)
This speeds up compression a lot on multicore systems.

https://bugzilla.redhat.com/show_bug.cgi?id=1029786

[Edited-by: Harald Hoyer: use getconf for cpu_count]

dracut.sh

index 03472ba16d237d8f67104f66ba7618156d1a6d70..bce2662fedd83730e43ff99a0976275811de9035 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -693,12 +693,14 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
 # eliminate IFS hackery when messing with fw_dir
 fw_dir=${fw_dir//:/ }
 
+cpu_count=$(getconf _NPROCESSORS_ONLN)
+
 # handle compression options.
 [[ $compress ]] || compress="gzip"
 case $compress in
     bzip2) compress="bzip2 -9";;
-    lzma)  compress="lzma -9";;
-    xz)    compress="xz --check=crc32 --lzma2=dict=1MiB";;
+    lzma)  compress="lzma -9 ${cpu_count:+-T$cpu_count}";;
+    xz)    compress="xz --check=crc32 --lzma2=dict=1MiB ${cpu_count:+-T$cpu_count}";;
     gzip)  compress="gzip -9"; command -v pigz > /dev/null 2>&1 && compress="pigz -9";;
     lzo)   compress="lzop -9";;
     lz4)   compress="lz4 -9";;