Re: Profiling compilation time

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

 



Ian Lance Taylor wrote:
Yang Zhang <yanghatespam@xxxxxxxxx> writes:

Ian Lance Taylor wrote:
In my experience, when not optimizing, C++ compilation time is normally
dominated by parsing and name lookup.
From an earlier thread "Precompiled headers and templates:"

Ian Lance Taylor wrote:
However, including explicit instantiations in the precompiled header
won't make any significant difference to compilation time.  The
precompiled header saves on parsing and name lookup time, it doesn't
save on code generation time.

I don't personally find that precompiled headers help with compilation
time all that much.  However, for some projects, ones with millions of
lines of header files included in every compilation, I expect that they
would help.
So PCHs only help with a very small fraction of the parsing + name
lookup?  (Already established that they wouldn't include template
instantiation component of paths.)

PCHs help with a large fraction of parsing and name lookup for those
header files which are included in the PCH.  The PCH implementation is
limited in that you can only include a single PCH in a compilation, and
it must be the thing which include first.  The more of your header files
that you can put into a single PCH, the more PCH will help you.
However, for the large projects which I have worked on, there is no
reasonable way to create a single large PCH which works across the
project, because different parts of the code use different sets of
header files, and it is not desirable to expose every part of the code
to every other part of the code.

Is this because, once created, the cost of including a PCH scales with the PCH's total size, and not with the just the size of the parts used/consumed by the including source?

The way I have been using PCHs is precisely the "single large PCH" approach: I put every system header used anywhere in the project into mypch.h, and I use "g++ -include mypch.h ..." (so that that's the first-included header). This *does* speed up compilation time for me, though I'd still like a better understanding of what the costs are.
--
Yang Zhang
http://www.mit.edu/~y_z/

[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