🐎 Allow xz to use all available CPUs
By default, xz only uses one CPU core even if multiple cores are available. If xz compression is chosen, allow xz to use all of the cores available. Signed-off-by: Major Hayden <major@redhat.com>
This commit is contained in:
parent
bc4fd565d6
commit
cab71e5b18
1 changed files with 22 additions and 2 deletions
|
|
@ -46,8 +46,28 @@ def main(tree, output_dir, options):
|
|||
return 1
|
||||
extra_args.append(f"--{compression}")
|
||||
|
||||
subprocess.run(["tar", *extra_args, "-cf", f"{output_dir}/{filename}", "-C", tree, "."],
|
||||
stdout=subprocess.DEVNULL, check=True)
|
||||
# Set environment variables for the tar operation.
|
||||
tar_env = {
|
||||
# Speed up xz by allowing it to use all CPU cores for compression.
|
||||
"XZ_OPT": "--threads 0"
|
||||
}
|
||||
|
||||
# Set up the tar command.
|
||||
tar_cmd = [
|
||||
"tar",
|
||||
*extra_args,
|
||||
"-cf", f"{output_dir}/{filename}",
|
||||
"-C", tree,
|
||||
"."
|
||||
]
|
||||
|
||||
# Make a tarball of the tree.
|
||||
subprocess.run(
|
||||
tar_cmd,
|
||||
stdout=subprocess.DEVNULL,
|
||||
check=True,
|
||||
env=tar_env
|
||||
)
|
||||
|
||||
return 0
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue