* Re: [Buildroot] [PATCH 1/1] core: Use of percent_defconfig seems to impact performance
2023-01-05 1:57 ` [Buildroot] [PATCH 1/1] " Nevo Hed via buildroot
@ 2023-01-07 20:15 ` Yann E. MORIN
2023-01-12 10:20 ` Peter Korsgaard
2023-01-21 22:27 ` Yann E. MORIN
1 sibling, 1 reply; 6+ messages in thread
From: Yann E. MORIN @ 2023-01-07 20:15 UTC (permalink / raw)
To: Nevo Hed; +Cc: thomas.petazzoni, buildroot
Nevo, All,
On 2023-01-04 20:57 -0500, Nevo Hed via buildroot spake thusly:
> 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@starry.com>
Thanks for the respin, I like it better than your first iteration, and
most importantly, better than my own implementation!
I however used most of my commit log, a=exteneded it even further,
provided my reproducibility script in the commit log and redid the
timings up to 1000 trees (heck, it's manageable now, so why not!).
I also slightly reformatted the code, to split the long lines.
Finally, I also added David as the reporter, and that his bug #14996
is now fixed.
Applied to master, thanks.
Regards,
Yann E. MORIN.
> ---
> Makefile | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 88f90cd2fa..ad866f1f24 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1013,13 +1013,14 @@ 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=$(or \
> + $(firstword $(foreach d, \
> + $(call reverse,$(TOPDIR) $(BR2_EXTERNAL_DIRS)),$(wildcard $(d)/configs/$@))), \
> + $(error "Can't find $@") \
> + ); \
> + $(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$${defconfig} \
> + $< --defconfig=$${defconfig} $(CONFIG_CONFIG_IN)
>
> update-defconfig: savedefconfig
>
> --
> 2.38.1
>
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [Buildroot] [PATCH 1/1] core: Use of percent_defconfig seems to impact performance
2023-01-05 1:57 ` [Buildroot] [PATCH 1/1] " Nevo Hed via buildroot
2023-01-07 20:15 ` Yann E. MORIN
@ 2023-01-21 22:27 ` Yann E. MORIN
2023-01-22 9:13 ` Yann E. MORIN
1 sibling, 1 reply; 6+ messages in thread
From: Yann E. MORIN @ 2023-01-21 22:27 UTC (permalink / raw)
To: Nevo Hed, Romain Naour, Peter Korsgaard; +Cc: thomas.petazzoni, buildroot
Nevo, All,
+Romain who reported an issue
+Peter the backport to stable branches
On 2023-01-04 20:57 -0500, Nevo Hed via buildroot spake thusly:
> 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).
n
> Signed-off-by: Nevo Hed <nhed+buildroot@starry.com>
> ---
> Makefile | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 88f90cd2fa..ad866f1f24 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1013,13 +1013,14 @@ 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
So, the following change:
> -%_defconfig: $(BUILD_DIR)/buildroot-config/conf $(1)/configs/%_defconfig outputmakefile
[--SNIP--]
> +%_defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
broke the build when the output directory ends with _defconfig. For
example:
$ make O=/some/path/meh_defconfig meh_defconfig
$ make O=/some/path/meh_defconfig
will break toward the end, with a rather weird issue:
Makefile:1015: *** "Can't find /some/path/meh_defconfig". Stop.
What looked weird, is two fold;
1. only the defconfig name should be reported, not the path
2. it happens after the filesystems are built
Tracing the build provides some clues;
$ make -d O=/some/path/meh_defconfig
[...]
Considering target file 'staging-finalize'.
File 'staging-finalize' does not exist.
Considering target file '/some/path/meh_defconfig/staging'.
File '/some/path/meh_defconfig/staging' does not exist.
Considering target file '/some/path/meh_defconfig'.
Looking for an implicit rule for '/some/path/meh_defconfig'.
Trying pattern rule with stem 'meh'.
Trying rule prerequisite '/some/path/meh_defconfig/build/buildroot-config/conf'.
Trying rule prerequisite 'outputmakefile'.
Found an implicit rule for '/some/path/meh_defconfig'.
Considering target file '/some/path/meh_defconfig/build/buildroot-config/conf'.
Looking for an implicit rule for '/some/path/meh_defconfig/build/buildroot-config/conf'.
Trying pattern rule with stem 'c'.
Found an implicit rule for '/some/path/meh_defconfig/build/buildroot-config/conf'.
Finished prerequisites of target file '/some/path/meh_defconfig/build/buildroot-config/conf'.
No need to remake target '/some/path/meh_defconfig/build/buildroot-config/conf'.
Considering target file 'outputmakefile'.
File 'outputmakefile' does not exist.
Finished prerequisites of target file 'outputmakefile'.
Must remake target 'outputmakefile'.
/home/ymorin/dev/buildroot/buildroot/master/support/scripts/mkmakefile /home/ymorin/dev/buildroot/buildroot/master /some/path/meh_defconfig
Putting child 0x55d4f3385ab0 (outputmakefile) PID 1231466 on the chain.
Live child 0x55d4f3385ab0 (outputmakefile) PID 1231466
GEN /some/path/meh_defconfig/Makefile
Reaping winning child 0x55d4f3385ab0 PID 1231466
Removing child 0x55d4f3385ab0 PID 1231466 from chain.
Successfully remade target file 'outputmakefile'.
Finished prerequisites of target file '/some/path/meh_defconfig'.
Prerequisite '/some/path/meh_defconfig/build/buildroot-config/conf' is older than target '/home/ymorin/dev/buildroot/buildroot/master/test/meh_defconfig'.
Prerequisite 'outputmakefile' of target '/some/path/meh_defconfig' does not exist.
Must remake target '/some/path/meh_defconfig'.
Makefile:1015: *** "Can't find /some/path/meh_defconfig". Stop.
So, it happens when trying to do staging-finalize. And this is becasue
we have (elided and reordered):
staging-finalize: $(STAGING_DIR_SYMLINK)
$(STAGING_DIR_SYMLINK): | $(BASE_DIR)
BASE_DIR := $(CANONICAL_O)
CANONICAL_O := $(shell mkdir -p $(O) >/dev/null 2>&1)$(realpath $(O))
So, at some point, we need to have something to generate
/some/path/meh_defconfig, and thus the %_defconfig rule kick in.
The rule is %_defconfig, and the stem is now /some/path/meh, while the
way we wrote the rule, it expects a plain name (i.e. without any '/').
And of course, there is no defconfig named '/some/path/meh_defconfig',
so the error path kicks in and boom.
But then, why did it not trigger before?
Thats because, before, the defconfig rule was something like:
%_defconfig: blabla foo/%_defconfig blabla
So the stem was on both side of the rule, and it would not kick in
because it was not an "implicit rule" (Makefile is not trivial, so maybe
I use the wrong terminology here), and because there would be an actual
file with that stem in its name.
So, I think we have two options:
1. quickly find a fix that is not totally hackish (but with Romain, we
could not find something trivial that worked)
2. revert this change, and resurect my alternate patch [0]
[0] https://lore.kernel.org/buildroot/20220920194645.670432-1-yann.morin.1998@free.fr/
Regards,
Yann E. MORIN.
> + @defconfig=$(or \
> + $(firstword $(foreach d, \
> + $(call reverse,$(TOPDIR) $(BR2_EXTERNAL_DIRS)),$(wildcard $(d)/configs/$@))), \
> + $(error "Can't find $@") \
> + ); \
> + $(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$${defconfig} \
> + $< --defconfig=$${defconfig} $(CONFIG_CONFIG_IN)
>
> update-defconfig: savedefconfig
>
> --
> 2.38.1
>
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 6+ messages in thread