From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13323 invoked by alias); 25 Mar 2009 07:39:02 -0000 Received: (qmail 13308 invoked by uid 22791); 25 Mar 2009 07:39:00 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SARE_MILLIONSOF,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-gx0-f207.google.com (HELO mail-gx0-f207.google.com) (209.85.217.207) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 25 Mar 2009 07:38:56 +0000 Received: by gxk3 with SMTP id 3so7173631gxk.8 for ; Wed, 25 Mar 2009 00:38:53 -0700 (PDT) Received: by 10.90.120.14 with SMTP id s14mr5373165agc.121.1237966732838; Wed, 25 Mar 2009 00:38:52 -0700 (PDT) Received: from ?18.138.1.33? (M7-100-4.MIT.EDU [18.138.1.33]) by mx.google.com with ESMTPS id 32sm972308aga.44.2009.03.25.00.38.52 (version=SSLv3 cipher=RC4-MD5); Wed, 25 Mar 2009 00:38:52 -0700 (PDT) Message-ID: <49C9DF8B.2040804@gmail.com> Date: Wed, 25 Mar 2009 07:39:00 -0000 From: Yang Zhang User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: Ian Lance Taylor CC: GCC-help Subject: Re: Profiling compilation time References: <49C8A53A.8000104@gmail.com> <49C9159E.108@gmail.com> <49C933FA.5060805@gmail.com> <49C9C9D3.9000502@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2009-03/txt/msg00320.txt.bz2 Ian Lance Taylor wrote: > Yang Zhang 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/