Re: GCC compilation performance under RAM starvation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2025-05-04 at 11:57 +0200, Florian Weimer wrote:
> * Krystian Kazmierczak via Gcc-help:
> 
> >   * Is this performance degradation considered normal for gcc under
> >   memory pressure?
> 
> Yes, I think it's expected.  Very little software these days is
> prepared to deal with swapping.

On some Linux systems, you could consider using
https://man7.org/linux/man-pages/man2/madvise.2.html
But GCC don't use it (and using it would be very system specific).

If you compile large software (like GCC itself) and want to optimize its build
time (but don't agree on spending money on hardware) you could instead play with
the number of jobs (the -j option to make).

If you really care about GCC itself consider coding your GCC plugin to deal with
that. I don't think it is very useful unless your GCC compiled translation units
are very strange (e.g. machine generated C++ files containing hundreds of C++
functions each having dozen of thousands of statements).

In that very unlikely scenario (but see https://arxiv.org/abs/1109.0779 ....) I
recommend instead spending your efforts on your C++ code generator (improving it
to generate smaller C++ functions but more of them), or adding inlining related
C++ pragmas, perhaps even some specific to your GCC plugin used to compile that
code.

The other bizarre scenario is very heavy and nested C++ templated functions and
their instanciations. For such code try also compiling with Clang (which
sometimes but not always performs better).

Linktime optimizations also could consume (in rare cases) a lot of RAM.

In practice, RAM (and computer hardware) is rather cheap and human developer
time costs a lot more... So buying more hardware is a pragmatic solution. 

Another possibility is using distributed compilation systems like
https://github.com/icecc/icecream (assuming you have several computers on the
same local Ethernet network). They would decrease compilation time, and you just
have to improve your building system (instead of improving GCC).

Regards.
-- 
Basile STARYNKEVITCH                            <basile@xxxxxxxxxxxxxxxxx>
8 rue de la Faïencerie                       http://starynkevitch.net/Basile/  
92340 Bourg-la-Reine                         https://github.com/bstarynk
France                                https://github.com/RefPerSys/RefPerSys




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux