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. As I said, they will help for projects in which million of lines of header files are included in every compilation. What I didn't quite manage to say was that it must be the exact same million lines in every compilation. Ian