This is the mail archive of the
mailing list for the GCC project.
Re: Faster compilation speed
- From: Noel Yap <yap_noel at yahoo dot com>
- To: Stan Shebs <shebs at apple dot com>
- Cc: Mike Stump <mrs at apple dot com>, gcc at gcc dot gnu dot org
- Date: Sat, 10 Aug 2002 16:07:57 -0700 (PDT)
- Subject: Re: Faster compilation speed
--- Stan Shebs <email@example.com> wrote:
> Noel Yap wrote:
> >Build speeds are most helped by minimizing the
> >of files opened and closed during the build.
> Is this assertion based on empirical measurement,
> and if so, for what
> source code and what system? For instance, the
> longest source file
> in GCC is about 15K lines, and at -O2, only a small
> percentage of
> time is spent messing with files. If I use
> -save-temps on cp/decl.c on
> one of my (Linux) machines, I get a total time of
> about 38 sec from
> source to asm. If I just compile decl.i, it's about
> 37 sec, so that's
> 1 sec for *all* preprocessing, including all file
This is a good question.
John Lakos in _Large-Scale C++ Software Development_
has performed a rudimentary case study. If the
conclusions are true, then your example indicates that
there wasn't much of a difference between the number
of files used when compiling decl.c and decl.i.
The study also indicates that having #include's within
header files is the largest contributor to the problem
(since nested #include's would increase the number of
file accesses combinatorially).
As another indication that the conclusion is true,
Lakos added guards around the #include lines
themselves and found compile times to dramatically
decrease. For example:
# include <header.h>
I can go on, but I doubt others on this list would
appreciate a reprint of the chapter. If you don't
have the book, I suggest at least finding a copy and
reading this chapter.
> Obviously, other programs will have different
> characteristics, and if
> you have one for which file opening/closing
> dominates compile time,
> that will be very interesting. But it's bad to try
> to optimize
> something before you have numerical evidence.
Would you agree with Lakos's findings as evidence to
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs