summaryrefslogtreecommitdiffstats
path: root/parallel_xz.sh
diff options
context:
space:
mode:
authorLaura Abbott <labbott@redhat.com>2019-11-06 12:47:55 -0500
committerLaura Abbott <labbott@redhat.com>2019-11-13 10:01:45 -0500
commitdba767169462cd40ad78590952674c41e221f41e (patch)
treec0e69e0c2f382a173f8acbb8f05f9d4b14a28e1a /parallel_xz.sh
parentd0a82f1e0fa60ffedb672422bf6779de24b8bd11 (diff)
downloadkernel-dba767169462cd40ad78590952674c41e221f41e.tar.gz
kernel-dba767169462cd40ad78590952674c41e221f41e.tar.xz
kernel-dba767169462cd40ad78590952674c41e221f41e.zip
Better xz compression
Borrowed from downstream, we can be a little bit smarter on how we compress modules.
Diffstat (limited to 'parallel_xz.sh')
-rwxr-xr-x[-rw-r--r--]parallel_xz.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/parallel_xz.sh b/parallel_xz.sh
index e69de29bb..bc08a548d 100644..100755
--- a/parallel_xz.sh
+++ b/parallel_xz.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Reads filenames on stdin, xz-compresses each in place.
+# Not optimal for "compress relatively few, large files" scenario!
+
+# How many xz's to run in parallel:
+procgroup=""
+while test "$#" != 0; do
+ # Get it from -jNUM
+ N="${1#-j}"
+ if test "$N" = "$1"; then
+ # Not -j<something> - warn and ignore
+ echo "parallel_xz: warning: unrecognized argument: '$1'"
+ else
+ procgroup="$N"
+ fi
+ shift
+done
+
+# If told to use only one cpu:
+test "$procgroup" || exec xargs -r xz
+test "$procgroup" = 1 && exec xargs -r xz
+
+# xz has some startup cost. If files are really small,
+# this cost might be significant. To combat this,
+# process several files (in sequence) by each xz process via -n 16:
+exec xargs -r -n 16 -P $procgroup xz