This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: query reg. gcc


Hi Zack,

Actually we  are trying to figure the main reason for the following:

We have around 50 files out of which a library is being made. Now when
we make a single compilation unit i.e. all the files #include in one
file and compile it the time taken is of the order of 5secs where as
if we compile the files individually and then make a library it takes
around 15X more time.

We believe that there can be two reasons for this:

a) In case of single compilation unit the files are loaded compiled
and kept in the memory and their subsequent reuse becomes faster. In
fact they are not loaded on the next use.
b)  There is a long include path these files lie on the network disks
in different locations e.g.
-I pathA -I pathB -I path C etc now suppose a file a.h is included by
the same include rule in
N number of source files then our understanding was that the search
might happen over and over again in case of sequential individual
compiles but from your emailI believe that this is not increasing the
time since OS takes care of the fact.

Precompiling looks like a solution but there are obvious issues like
dependency organization, recompilation and context specific compiles
for RELEASE, DEBUG etc. We were just wondering since we already know
the fact that this is compiled from the same directory and through one
single  makefile and the same rules apply to all the files of this
particular compile in terms of include paths. Is there any existing
option in GCC to cache files like a.h when its read the first time
because there is a high probability of this file getting used later in
the same compile sequentially. Since we have already compiled this
file once cant the compiler ensure that the paths of the files and
compiled form of the header is persistent for the compile being done
through the same rules (i.e) the same makefile over a subdirectory.
This way we might be able to automatically the compile time
performance of a single compilation unit at least for a particular
subdirectory. This can cut the compile time drastically and moreover
single compilation unit is ugly, hackish and dangerous for namespace
etc clashes and precompiled headers a difficult choice for large
projects.  I am not sure if there is a way to do this directly in the
existing GCC version.
 
Any comments on this would be really appreciated and would help us cut
the more than required compile times that we are spending.

Thanks,
Shachin


================================================================
It is worth pointing out that every operating system in wide use will
cache the text of the headers in memory; they will not be reread from
disk for every compilation, only when other memory users force the OS 
to throw away the cached copy.

This happens completely transparently to GCC, and isn't going to make
your build any faster than it already is; I just point it out because
your phrasing implies that you think it's being reread from disk each
time.

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]