[U-Boot] [PATCH] Reduce build times

Daniel Schwierzeck daniel.schwierzeck at googlemail.com
Thu Nov 3 16:25:39 CET 2011


Hi Wolfgang,

On Wed, Nov 2, 2011 at 11:48 PM, Wolfgang Denk <wd at denx.de> wrote:
> Dear Daniel Schwierzeck,
>
> In message <CACUy__UjmnRYKMWiMB9pqr0_dS6cgiyo-MsoVY4eSH2zT6ZKHA at mail.gmail.com> you wrote:
>>
>> On Wed, Nov 2, 2011 at 7:54 AM, Wolfgang Denk <wd at denx.de> wrote:
>> > U-Boot Makefiles contain a number of tests for compiler features etc.
>> > which so far are executed again and again. =C2=A0On some architectures
>> > (especially ARM) this results in a large number of calls to gcc.
>> >
>> > This patch makes sure to run such tests only once, thus largely
>> > reducing the number of "execve" system calls.
>> >
>>
>> maybe you want to try this experimental patch.
>> http://patchwork.ozlabs.org/patch/123313/
>>
>> It significantly reduces the count of gcc calls by caching the results.
>> This also improves compilation times.
>
> Do you suggest this in addition or instead of the patch I posted?
>
> Can you provide some measurements of build times and/or execve system
> calls?

I ran some additonal tests with interesting results.

Board: ARM, Tegra2, seaboard
Toolchain: Sourcery G++ Lite 2011.03-41 for ARM GNU/Linux
Workstation: Core 2 Duo E6600 @2,4 Ghz, 4 GB, x86_64

I patched the cc-option macro to count all calls like this:

 cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
-               > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
+               > /dev/null 2>&1; then echo "$(1)"; echo "$1" >>
$(OBJTREE)/cc-option; else echo "$(2)"; fi ;)

I ran the steps below for following source trees:
- unmodified HEAD
- only your patch
- only my patch
- both patches combined

Steps:
Complete build:
-> git clean -xdf
-> CROSS_COMPILE=/opt/codesourcery/arm-2011.03/bin/arm-none-linux-gnueabi-
make seaboard_config
-> time CROSS_COMPILE=/opt/codesourcery/arm-2011.03/bin/arm-none-linux-gnueabi-
CACHE_CC_OPTIONS=y make -s
-> cat cc-option | wc -l

Incremental rebuild:
-> time CROSS_COMPILE=/opt/codesourcery/arm-2011.03/bin/arm-none-linux-gnueabi-
CACHE_CC_OPTIONS=y make -s

Complete build with strace:
-> git clean -xdf
-> CROSS_COMPILE=/opt/codesourcery/arm-2011.03/bin/arm-none-linux-gnueabi-
make seaboard_config
-> CROSS_COMPILE=/opt/codesourcery/arm-2011.03/bin/arm-none-linux-gnueabi-
CACHE_CC_OPTIONS=y strace -f -e trace=execve -o strace.out make -s
-> grep execve strace.out | wc -l

Results:
unmodified HEAD:
real	1m11.540s
user	2m7.170s
sys	0m19.840s

cc-option calls 3024

real	0m20.176s
user	0m39.260s
sys	0m6.480s

execve calls 16502

only your patch:
real	0m32.371s
user	0m47.440s
sys	0m7.900s

cc-option calls 864

real	0m9.606s
user	0m16.890s
sys	0m2.940s

execve calls 5906

only my patch:
real	0m28.187s
user	0m56.030s
sys	0m7.820s

cc-option calls 20

real	0m5.013s
user	0m13.300s
sys	0m2.200s

execve calls 7415

both patches combined:
real	0m19.777s
user	0m28.010s
sys	0m4.100s

cc-option calls 8

real	0m2.902s
user	0m6.400s
sys	0m1.070s

execve calls 3329

Conclusion:
- complete build time reduced from 1m11s to 20s
- incremental rebuild time reduced from 20s to 3s
- cc-option calls reduced from 3024 to 8
- execve calls reduced from 16502 to 3329

Best regards,
Daniel


More information about the U-Boot mailing list