xz_auto: Enable multi-threaded xz
When cros_build_lib.FindCompressor returns xz, it doesn't have a way to
indicate that we should enable parallelism with -T0. Create a tiny
wrapper in chromite/scripts that just runs xz with -T0 inserted at the
front of its args so we can get parallelism.
This particularly benefits the SDKPackage stage, but it will potentially
speed up other uses of xz as well. Locally, this appears to reduce the
time needed to create the SDK image by roughly 95%. Builders will
probably see a smaller impact because the disk speeds are different.
BUG=None
TEST=chromiumos-sdk tryjob
Change-Id: Ieb5bd4c5207bf8f464dd0ed7f1368401df170b2a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1955458
Tested-by: Benjamin Gordon <bmgordon@chromium.org>
Reviewed-by: Chris McDonald <cjmcdonald@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Benjamin Gordon <bmgordon@chromium.org>
diff --git a/scripts/xz_auto.py b/scripts/xz_auto.py
new file mode 100644
index 0000000..615fff5
--- /dev/null
+++ b/scripts/xz_auto.py
@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Run xz from PATH with a thread for each core in the system."""
+
+from __future__ import print_function
+
+import os
+
+
+def main(argv):
+ os.execvp('xz', ['xz', '-T0'] + argv)