diff options
author | Thorsten Leemhuis <fedora@leemhuis.info> | 2019-12-05 00:33:21 +0100 |
---|---|---|
committer | Thorsten Leemhuis <fedora@leemhuis.info> | 2019-12-05 00:34:15 +0100 |
commit | 91b06924d96afcf0f1d0e9c547eb15f01c78fffb (patch) | |
tree | 40017dfdc10bbf6ee55a5affce794af3e587263c /parallel_xz.sh | |
parent | 2adce5aeb6c95194af74c43c1598563c4748823a (diff) | |
parent | 6b45f47575b44ead23d61138c8f080fbb9f81f80 (diff) | |
download | kernel-91b06924d96afcf0f1d0e9c547eb15f01c78fffb.tar.gz kernel-91b06924d96afcf0f1d0e9c547eb15f01c78fffb.tar.xz kernel-91b06924d96afcf0f1d0e9c547eb15f01c78fffb.zip |
merge originkernel-5.4.2-350.vanilla.knurd.1.fc31
Diffstat (limited to 'parallel_xz.sh')
-rwxr-xr-x | parallel_xz.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/parallel_xz.sh b/parallel_xz.sh new file mode 100755 index 000000000..bc08a548d --- /dev/null +++ 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 |