summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schiller <ms@dev.tdt.de>2019-10-07 06:52:08 +0200
committerPetr Štetiar <ynezz@true.cz>2019-10-09 09:13:44 +0200
commitb204fcdb07c2498e349eab6f93e3ecdfa9f8589c (patch)
tree53d2af096ee5001b761be5cc7475430801dd8bdc
parenta92f74ba8db81b8f1dac92ed3d0756b4ba486c39 (diff)
downloadopenwrt-b204fcdb07c2498e349eab6f93e3ecdfa9f8589c.tar.gz
openwrt-b204fcdb07c2498e349eab6f93e3ecdfa9f8589c.tar.bz2
openwrt-b204fcdb07c2498e349eab6f93e3ecdfa9f8589c.zip
target/imagebuilder: use multi-thread support for xz compression
This speeds up the packing of the imagebuilder a lot: imagebuilder-T0.tar.xz real 0m25.199s user 2m45.967s sys 0m1.218s imagebuilder-T1.tar.xz real 2m02.543s user 2m02.418s sys 0m1.653s imagebuilder-T2.tar.xz real 1m03.684s user 1m59.931s sys 0m0.587s imagebuilder-T3.tar.xz real 0m48.033s user 2m02.904s sys 0m0.637s imagebuilder-T4.tar.xz real 0m38.963s user 2m15.521s sys 0m0.783s imagebuilder-T5.tar.xz real 0m37.994s user 2m21.461s sys 0m0.919s imagebuilder-T6.tar.xz real 0m39.524s user 2m48.115s sys 0m1.279s imagebuilder-T7.tar.xz real 0m34.061s user 2m45.097s sys 0m1.174s imagebuilder-T8.tar.xz real 0m27.286s user 2m55.449s sys 0m1.329s imagebuilder-T9.tar.xz real 0m25.205s user 2m44.894s sys 0m1.208s To keep the output reproducible in any case, we enforce a minimum amount of 2 threads. Signed-off-by: Martin Schiller <ms@dev.tdt.de> [refactored into reusable NPROC var, more verbose commit message] Signed-off-by: Petr Štetiar <ynezz@true.cz>
-rw-r--r--rules.mk1
-rw-r--r--target/imagebuilder/Makefile2
2 files changed, 2 insertions, 1 deletions
diff --git a/rules.mk b/rules.mk
index b140fbca70..f1ca735f2e 100644
--- a/rules.mk
+++ b/rules.mk
@@ -70,6 +70,7 @@ TARGET_SUFFIX=$(call qstrip,$(CONFIG_TARGET_SUFFIX))
BUILD_SUFFIX:=$(call qstrip,$(CONFIG_BUILD_SUFFIX))
SUBDIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR})
BUILD_SUBDIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR})
+NPROC:=$(shell sysctl -n hw.ncpu 2>/dev/null || nproc)
export SHELL:=/usr/bin/env bash
IS_PACKAGE_BUILD := $(if $(filter package/%,$(BUILD_SUBDIR)),1)
diff --git a/target/imagebuilder/Makefile b/target/imagebuilder/Makefile
index 05c7cf3318..b463feb456 100644
--- a/target/imagebuilder/Makefile
+++ b/target/imagebuilder/Makefile
@@ -86,7 +86,7 @@ endif
(cd $(PKG_BUILD_DIR); find staging_dir/host/bin/ $(IB_LDIR)/scripts/dtc/ -type f | \
$(XARGS) $(SCRIPT_DIR)/bundle-libraries.sh $(PKG_BUILD_DIR)/staging_dir/host)
STRIP=sstrip $(SCRIPT_DIR)/rstrip.sh $(PKG_BUILD_DIR)/staging_dir/host/bin/
- $(TAR) -cf - -C $(BUILD_DIR) $(IB_NAME) | xz -zc -7e > $@
+ $(TAR) -cf - -C $(BUILD_DIR) $(IB_NAME) | xz -T$(if $(filter 1,$(NPROC)),2,0) -zc -7e > $@
download:
prepare: