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

From: Lorenzo Stoakes
Date: Sat Jul 27 2024 - 14:45:48 EST


On Sat, Jul 27, 2024 at 09:26:43AM GMT, Linus Torvalds wrote:
> On Sat, 27 Jul 2024 at 01:08, Lorenzo Stoakes
> <lorenzo.stoakes@xxxxxxxxxx> wrote:
> >
> > 62603617./drivers/staging/media/atomisp/pci/isp/kernels/ynr/ynr_1.0/ia_css_ynr.host.o.pre
>
> Heh.
>
> Longest line is drivers/.../ia_css_ynr.host.c:71 (27785kB)
>
> yeah, that's a single line that expands to 27MB in size.
>
> And yes, that line is one single min(...) expression with arguments
> that are then in turn macros with other nested min/max arguments.
>
> See also drivers/staging/media/atomisp/pci/sh_css_frac.h.
>
> On my fairly beefy (admittedly more cores than single-thread) machine,
> just generating the preprocessor file takes just under 20s.
>
> Building the object file is actually faster at "only" 8.5s for that
> one file, because it uses the built-in preprocessor and never writes
> it out, and most of the actual preprocessing result is trivial stuff
> that gets thrown away immediately.
>
> Linus

I attach a patch which addresses some of the worst culprits here including
that staging monstrosity. Changing the sDIGIT_FITTING() and
uDIGIT_FITTING() macros affects a ton of other related drivers so has an
outsized impact.

Another big one I tackled is the NET_SKB_PAD define causing slightly hidden
nesting, we can just replace that with a dumb #if and get rid of that.

I also moved MVPP2_SKB_HEADROOM to a clamp_t().

I noticed a bunch of xfs stuff that's slow too, but tracked that down to
<linux/bio.h> which I see you're covering in another thread with Willy.

There are other bits and pieces, but this seems to cover the most egregious
cases.

This patch reduces preprocessor-generated output for allmodconfig from
102,966,525,841 bytes (!) to 102,764,954,617 on my system, thus saves
~200MB of generated output.

----8<----