[Buildroot] [PATCH] core: Use of percent_defconfig seems to impact performance
Nevo Hed
nhed+buildroot at starry.com
Wed Oct 19 17:51:51 UTC 2022
Noticed a significant slowdown with rise of number of external trees
in our env. This slowdown seemed to be related to invocations if the
percent_defconfig function (GNU Make 4.3).
While I have not do a deep dive in analyzing the performance issue, it
felt like redefining the %_defconfig rule N times impact performance.
This patch makes %_defconfig a single rule which combines uses the
first return of a wildcard expression.
Timing (seconds) of `make pc_x86_64_bios_defconfig` with 1-8 external
trees:
#Trees Before After
1 0.38 0.37
2 0.32 0.31
3 0.31 0.33
4 0.36 0.32
5 0.45 0.35
6 1.26 0.36
7 9.10 0.36
8 85.93 0.42
Signed-off-by: Nevo Hed <nhed+buildroot at starry.com>
---
Makefile | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index ec7c034ac1..a8298dd5fd 100644
--- a/Makefile
+++ b/Makefile
@@ -1010,13 +1010,12 @@ oldconfig syncconfig olddefconfig: $(BUILD_DIR)/buildroot-config/conf outputmake
defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
@$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)
-define percent_defconfig
-# Override the BR2_DEFCONFIG from COMMON_CONFIG_ENV with the new defconfig
-%_defconfig: $(BUILD_DIR)/buildroot-config/conf $(1)/configs/%_defconfig outputmakefile
- @$$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(1)/configs/$$@ \
- $$< --defconfig=$(1)/configs/$$@ $$(CONFIG_CONFIG_IN)
-endef
-$(eval $(foreach d,$(call reverse,$(TOPDIR) $(BR2_EXTERNAL_DIRS)),$(call percent_defconfig,$(d))$(sep)))
+%_defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
+ @defconfig=$(firstword $(foreach d,\
+ $(call reverse,$(TOPDIR) $(BR2_EXTERNAL_DIRS)),$(wildcard $(d)/configs/$@))); \
+ if [ -z "$${defconfig}" ]; then echo "Can't find $@" >&2; exit 1; fi; \
+ $(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$${defconfig} \
+ $< --defconfig=$${defconfig} $(CONFIG_CONFIG_IN)
update-defconfig: savedefconfig
--
2.37.3
More information about the buildroot
mailing list