This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: help with improving compile times
- From: Markus Trippelsdorf <markus at trippelsdorf dot de>
- To: Mason <slash dot tmp at free dot fr>
- Cc: GCC help <gcc-help at gcc dot gnu dot org>
- Date: Mon, 15 May 2017 15:16:38 +0200
- Subject: Re: help with improving compile times
- Authentication-results: sourceware.org; auth=none
- References: <7758193.5tzhTicriZ@mars> <20170515120126.GB283@x4> <282f5fd5-102f-5b1e-ab31-2c2ee751ec85@free.fr>
On 2017.05.15 at 15:07 +0200, Mason wrote:
> On 15/05/2017 14:01, Markus Trippelsdorf wrote:
>
> > On 2017.05.15 at 12:11 +0200, Matthias Kretz wrote:
> >
> >> I'm looking for help on improving the compile times of my unit tests. Compile
> >> times of >60s per TU is making my life hard.
> >> Alternatively, if you can tell me there's nothing I can do, then I can accept
> >> my fate and stop worrying about compile time optimizations.
> >>
> >> Picking one example from my ~500 unit test TUs:
> >> You can see the source at https://github.com/VcDevel/Vc/blob/
> >> c807aa0c841950e50ec7d370c9c22d6038c7e068/tests/loadstore.cpp
> >>
> >> Note that TEST_TYPES (line 109) produces 91 instantiations of the
> >> `load_store<VU>` function template from an outer product of two type lists.
> >> (I'd actually like to make the type list larger by a factor of 13, but that
> >> just blows the compiler up.)
> >>
> >> Attached is the output of -ftime-report. I must say I was surprised to see
> >> "phase opt and generate" with 62.5s and 95% of the total time, as well as 84%
> >> of the memory usage. Though, OTOH, the resulting binary is 4.4MiB large with
> >> about 3/4 of it being the .text section.
> >>
> >> If you have any ideas what I could do (other than "test less"), I'd like to
> >> try it.
> >
> > Enabling Link Time Optimization may help: -flto=<some number, e.g. the
> > number of cores you have>
>
> I'm confused. Are you suggesting that requesting /more/ optimizations
> might reduce compile+link time?
Yes. For huge compilation units (like the template heavy example above)
-flto=<number of 'cores'> reduces compile+link time, because it causes
the backend to run in parallel.
--
Markus