Blame 0030-Run-xz-and-lzma-with-multiple-threads.patch

Harald Hoyer 4734ec
From a3bfaa191958c4b70d6c674f972c3b911f8b1bfa Mon Sep 17 00:00:00 2001
Harald Hoyer 4734ec
From: Vratislav Podzimek <vpodzime@redhat.com>
Harald Hoyer 4734ec
Date: Wed, 13 Nov 2013 13:20:39 +0100
Harald Hoyer 4734ec
Subject: [PATCH] Run 'xz' and 'lzma' with multiple threads
Harald Hoyer 4734ec
Harald Hoyer 4734ec
This speeds up compression a lot on multicore systems.
Harald Hoyer 4734ec
Harald Hoyer 4734ec
https://bugzilla.redhat.com/show_bug.cgi?id=1029786
Harald Hoyer 4734ec
Harald Hoyer 4734ec
[Edited-by: Harald Hoyer: use getconf for cpu_count]
Harald Hoyer 4734ec
---
Harald Hoyer 4734ec
 dracut.sh | 6 ++++--
Harald Hoyer 4734ec
 1 file changed, 4 insertions(+), 2 deletions(-)
Harald Hoyer 4734ec
Harald Hoyer 4734ec
diff --git a/dracut.sh b/dracut.sh
Harald Hoyer 4734ec
index 03472ba..bce2662 100755
Harald Hoyer 4734ec
--- a/dracut.sh
Harald Hoyer 4734ec
+++ b/dracut.sh
Harald Hoyer 4734ec
@@ -693,12 +693,14 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
Harald Hoyer 4734ec
 # eliminate IFS hackery when messing with fw_dir
Harald Hoyer 4734ec
 fw_dir=${fw_dir//:/ }
Harald Hoyer 4734ec
 
Harald Hoyer 4734ec
+cpu_count=$(getconf _NPROCESSORS_ONLN)
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
 # handle compression options.
Harald Hoyer 4734ec
 [[ $compress ]] || compress="gzip"
Harald Hoyer 4734ec
 case $compress in
Harald Hoyer 4734ec
     bzip2) compress="bzip2 -9";;
Harald Hoyer 4734ec
-    lzma)  compress="lzma -9";;
Harald Hoyer 4734ec
-    xz)    compress="xz --check=crc32 --lzma2=dict=1MiB";;
Harald Hoyer 4734ec
+    lzma)  compress="lzma -9 ${cpu_count:+-T$cpu_count}";;
Harald Hoyer 4734ec
+    xz)    compress="xz --check=crc32 --lzma2=dict=1MiB ${cpu_count:+-T$cpu_count}";;
Harald Hoyer 4734ec
     gzip)  compress="gzip -9"; command -v pigz > /dev/null 2>&1 && compress="pigz -9";;
Harald Hoyer 4734ec
     lzo)   compress="lzop -9";;
Harald Hoyer 4734ec
     lz4)   compress="lz4 -9";;