On Mon, Apr 16, 2012 at 3:38 PM, Diego Novillo <dnovi...@google.com> wrote:
>> I'm not sure PPH will replace PCH - will it?
>
> In theory, it may.  But it's not in the immediate plans.

IMHO, the case for including PPH would be much stronger if replacing
PCH would be included in the immediate to mid-term plans. The current
implementation of PCH has so many disadvantages, both for GCC
internals and for users, that it is hardly useful. It seems to have
been developed with one particular use in mind: projects with OHRTA
(One Header to Rule Them All), like Apple's Objective-C library
framework.

To get an idea of how widely used PCH is, I looked at bugzilla. GCC
has had PCH since GCC 3.4, which is almost 8 years old (18 April
2004). In that time, 93 bugs about PCH have been filed in Bugzilla, of
which 17 were duplicates, and 13 were invalid (including 3
WORKSFORME). 26 bugs remain open (only two have been assigned to
someone to fix, with no action since forever). So either PCH is
remarkably bug-free, or hardly anyone is actually using it.

(For comparison, 3256 c++ bugs were filed since GCC 3.4, with 414
duplicates, 488 invalid, and 521 remaining open.)

Distributors obviously have better sources of data to "measure" how
useful PCH is, and I'd be curious to know e.g. how many packages in
Fedora or openSuSE use PCH...

> The big thing that PCH has going for it is load speed.  PCH is almost
> instantaneous, PPH isn't.  A 1Gb PCH file can be restored in <1s, the
> corresponding PPH file needs ~8s to restore.  The implementation can
> still be tuned for performance, but it will never be as fast as a
> couple of mmap operations.

I think it is not reasonable to compare PCH to PPH like that. Perhaps
that 8s is still only a small amount of time for the whole compilation
process, and still only a fraction of the time for lexing+parsing the
underlying source code.


> PPH is a much smaller representation (that 1Gb PCH file can be
> represented in <400Mb in PPH) and more flexible (almost any arbitrary
> subset of headers can be turned into separate PPH images).

Another advantage would be that PPHs can be made practically
machine-indepenent (GCC is not quite ready for it, but at least in
theory this could be done with PPHs but not with a PCH).

Others have already compared the GCC PCH and PTH/PPH approaches, so
for some arguments against GCC's existing PCH implementation and some
arguments for PPH/PTH see:

 http://clang.llvm.org/docs/PTHInternals.html
 http://gcc.gnu.org/wiki/PCHHaters


> So, it's not clear whether we will want to replace PCH with PPH.
> Flexibility costs raw performance.  If the performance gap can be
> bridged, we may want to consider it in the future.

I think the other advantages and disadvantages, apart from
performance, should also be considered in such a decision.

Ciao!
Steven

Reply via email to