Re: [PATCH 0/7] minmax: reduce compilation time

From: Lorenzo Stoakes
Date: Fri Jul 26 2024 - 14:57:17 EST


On Fri, Jul 26, 2024 at 11:24:09AM GMT, Linus Torvalds wrote:
> On Fri, 26 Jul 2024 at 11:13, Lorenzo Stoakes
> <lorenzo.stoakes@xxxxxxxxxx> wrote:
> >
> > 5,447,539 ./arch/x86/xen/setup.o.pre
>
> Can you perhaps do some kind of "max expansion" on all the
> preprocessor files (you seem to have done it by changing the ".c.o"
> rule to just spit it out as "o.pre", which sounds fine).

Yeah I simply hacked in a gcc -E, ugly but effective, e.g. prepending
cmd_cc_o_c in scripts/Makefile.build with:

cmd_cc_o_c = $(CC) $(c_flags) -E $< > $@.pre; \

(with credit to Arnd, who came up with a timing patch using a similar
technique, I just super trivially adapted to do this instead).

I therefore generate a bunch of .pre files, + run this to get total
numbers:

find . -iname '*.pre' -exec du -cb {} + | grep total$ | cut -f1 | paste -sd+ - | bc

So I have the numbers for all of the files. Did you want me to post the
numbers somewhere, or were you after someting cleverer, not sure what you
mean by "max expansion"?

>
> For example, this trivial patch seems to fix the setup.c expansion by
> about an order of magnitude (ie 50M -> 5M).
>
> Entirely untested, but looks ObviouslyCorrect(tm) to me.
>
> Linus
>
> Linus

Yeah this has a big impact, with just this patch we go from 51,407,944 to
4,351,747 locally for me, so match your results.

Patch looks obviously correct to me, I wonder if we should just apply that
now and take out one of the worst offenders while we figure out how to fix
the broader problem?

Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx> fwiw on that :)