public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Precompiled Header support for GCC-3.4
@ 2004-09-09 12:30 Prasad Kulkarni
  2004-09-09 20:32 ` Mike Stump
  0 siblings, 1 reply; 5+ messages in thread
From: Prasad Kulkarni @ 2004-09-09 12:30 UTC (permalink / raw)
  To: gcc

Hi ,

 I was just trying my hand at precompiled header support provided by
gcc 3.4. In one my project I have got 4 modules. Modules 1 and 2 are
relatively small where as 3 and 4 are large.   I included all the
files needed by modules1 and 2 into a single header file and generated
a PCH for it. When I compiled them with the support of PCH I found
considerable speed in build time.

 But for modules 3 and 4 it didn't work. As these are large modules
no. of header files needed are quite high. When I generated a single
PCH and compiled it took larger amount of time than the one without
PCH. (1.5 times slower). Also the size of PCH file was very large. 
Then I reduced the no. of files and kept only those which are used by
most of translational units build time was faster. But there is only
slilght decrease in build time compared to one without PCH support.

 Then I generated one PCH each of translational unit. Still its build
time higher than the one without PCH.

  Can anybody please enlighten me about the logic behind this? If I
have lots of header files for a module  and want decrease the build
time of module is PCH right thing to go? If yes, then how I can do it?

Also is there any special flags are there that I need to  add or omit
while compilation that may effect my build time considerably? Are
there any any special configuration options that I need to specify
while building gcc itself to take complete advantage of PCH?

Thanks and Regards
--Prasad

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Precompiled Header support for GCC-3.4
  2004-09-09 12:30 Precompiled Header support for GCC-3.4 Prasad Kulkarni
@ 2004-09-09 20:32 ` Mike Stump
  2004-09-10  5:27   ` Prasad Kulkarni
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Stump @ 2004-09-09 20:32 UTC (permalink / raw)
  To: Prasad Kulkarni; +Cc: gcc

On Sep 9, 2004, at 5:06 AM, Prasad Kulkarni wrote:
>  I was just trying my hand at precompiled header support provided by
> gcc 3.4. In one my project I have got 4 modules.

I don't know what a module is.

> Then I generated one PCH each of translational unit. Still its build
> time higher than the one without PCH.
>
> Can anybody please enlighten me about the logic behind this?

Sure, PCH has a non-zero overhead, that makes it not worth while if you 
use a PCH file once (for one translation unit), and never again.  If 
you change the .c files and never modify .h files, then you might want 
to do this for rapid development, otherwise, no.

> If I have lots of header files for a module and want decrease the build
> time of module is PCH right thing to go? If yes, then how I can do it?

No, this isn't what PCH is and does.

> Also is there any special flags are there that I need to  add or omit
> while compilation that may effect my build time considerably? Are
> there any any special configuration options that I need to specify
> while building gcc itself to take complete advantage of PCH?

If you only have 4 translation units, you aren't the type of user PCH 
targets.  PCH targets people with 200 units, each 20 lines long, with 
200K worth of headers in each unit, and the same 200K worth of headers 
in each unit.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Precompiled Header support for GCC-3.4
  2004-09-09 20:32 ` Mike Stump
@ 2004-09-10  5:27   ` Prasad Kulkarni
  2004-09-10 15:34     ` Daniel Jacobowitz
  2004-09-10 18:55     ` Mike Stump
  0 siblings, 2 replies; 5+ messages in thread
From: Prasad Kulkarni @ 2004-09-10  5:27 UTC (permalink / raw)
  To: Mike Stump; +Cc: gcc

Hi Mike,

     Thanks for replying. Basically I am using auto tools to build my
project. I am referring to each of directory in my project suite as a
module.

For ex. for testing I have created a library out of CPPUnit.   All the
source files of CPPUnit reside in a directory named CPPUnit. I am
referring to each directory as a module. I am referring to a .cpp file
as a source file and .h file as a header file.CPPUnit module contains
11 source files and 15 header files. Similary I have got other 3
modules.

Module 2 contains 18 source files and 24 header files. Module 3
contains 26 source files and 47 header files. Module 4 contains 296
source files and 259 header files.

First I compiled all the 4 modules without PCH support. Build time
was: 14 Min. 49 Sec.

Then I tried to include all the header files of all the modules into a
single header file create a PCH and compiled. Build time was: 20min.
2sec.  It was much slower than without PCH support.

Then I selected few of the files which are used by all the modules and
created PCH out of it. Build time was: 13min. 34sec.

Then a created a module specifiic header file and compiled with PCH
support. Build time was: 13min 28sec.

There is not significant decrease build time because of PCH support.
One thing I observed is that as the no. of header files included in
each of PCH goes on increasing build time also increases. I think its
supposed to happen in the other way. I don't understand this. Is there
anything wrong with the way I am trying out the things? Or any of the
compiler flags is missing?

Currently I am using following compiler flags for compilation.

g++ -DHAVE_CONFIG_H -I. -I. -I.. -include ../PCH/cppunitincludes.h 
-I../STL/stlport     -g -O2 -D_REENTRANT -DSLEXT='".so"' -DREDHAT9
-I/opt/sfw/include -D_DEBUG -Wall -DLINUX -fPIC -DPIC  -c -o
TestCase.o


Thanks and Regards
Prasad

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Precompiled Header support for GCC-3.4
  2004-09-10  5:27   ` Prasad Kulkarni
@ 2004-09-10 15:34     ` Daniel Jacobowitz
  2004-09-10 18:55     ` Mike Stump
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2004-09-10 15:34 UTC (permalink / raw)
  To: Prasad Kulkarni; +Cc: Mike Stump, gcc

On Fri, Sep 10, 2004 at 10:25:27AM +0530, Prasad Kulkarni wrote:
> Currently I am using following compiler flags for compilation.
> 
> g++ -DHAVE_CONFIG_H -I. -I. -I.. -include ../PCH/cppunitincludes.h 
> -I../STL/stlport     -g -O2 -D_REENTRANT -DSLEXT='".so"' -DREDHAT9
> -I/opt/sfw/include -D_DEBUG -Wall -DLINUX -fPIC -DPIC  -c -o
> TestCase.o

You may want to try -Winvalid-pch.

-- 
Daniel Jacobowitz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Precompiled Header support for GCC-3.4
  2004-09-10  5:27   ` Prasad Kulkarni
  2004-09-10 15:34     ` Daniel Jacobowitz
@ 2004-09-10 18:55     ` Mike Stump
  1 sibling, 0 replies; 5+ messages in thread
From: Mike Stump @ 2004-09-10 18:55 UTC (permalink / raw)
  To: Prasad Kulkarni; +Cc: gcc

On Thursday, September 9, 2004, at 09:55  PM, Prasad Kulkarni wrote:
> There is not significant decrease build time because of PCH support.

Compile with -H and/or -Winvalid-pch and ensure that all the PCH files 
are actually used in all compilations.  I suspect, you may be using it 
wrong.

> One thing I observed is that as the no. of header files included in
> each of PCH goes on increasing build time also increases.

Sounds generally wrong.  There will be some increase, in some cases.  
-H will tell you what's going on.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-09-10 17:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-09 12:30 Precompiled Header support for GCC-3.4 Prasad Kulkarni
2004-09-09 20:32 ` Mike Stump
2004-09-10  5:27   ` Prasad Kulkarni
2004-09-10 15:34     ` Daniel Jacobowitz
2004-09-10 18:55     ` Mike Stump

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).