[prev in list] [next in list] [prev in thread] [next in thread] 

List:       flightgear-users
Subject:    [Flightgear-users] Re: ccache
From:       Melchior FRANZ <a8603365 () unet ! univie ! ac ! at>
Date:       2004-02-08 22:09:08
Message-ID: 200402082309.08901 () pflug2 ! gphy ! univie ! ac ! at
[Download RAW message or body]

* Jonathan Richards -- Sunday 08 February 2004 22:02:
> Melchior - Gruße Gott!
[1] 

Servus[2],


Before I answer your questions, I'd like to (try to) explain what ccache
does, and thus, where and how it can help:

1. ccache is called instead of gcc/g++. This can be automated by defining
   export CC="ccache gcc"
   export CXX="ccache g++"
   before you configure, preferably in your personal build script.

2. It pre-processes every source file:
   a. expands it by feeding it through the preprocessor (gcc -E)
   b. removes all remaining comments
   c. removes all insignificant spaces

3. Now it looks if this exact code was already compiled by comparing a
   checksum. If not, then it compiles and puts the object into the cache,
   together with make's command line and the compiler's error messages.
   Otherwise it outputs the cached command line and error messages and
   delivers the pre-compiled object file.

In the worst case a ccache run is slightly slower(!) than direct g++,
but in the best case it "compiles" on my computer (2.4GHz) after having
made "clean":

  plib       in  25 seconds,
  SimGear    in  41 seconds,
  FlightGear in  1 minute and 56 seconds
  Atlas      in  5 seconds
  fgrun      in  4 seconds

And if you take a trivial change in a header file like simgear/props/props.hxx
that is included almost everywhere, then make would compile pretty much
everything, while ccache would only compile the files that are actually
affected. There's no effect on linking, which always has to be done like
without ccache. 



> Firstly, in general, I don't do a 'make clean', just autogen, make, make 
> install.  In this case, doesn't 'make' itself keep track of changes?

Yes, but ...



> To quote 'info make': "The `make' utility automatically determines which 
> pieces of a large program need to be recompiled,

It doesn't compile what "needs" to be compiled, but everything that
contains a file with changed modification time. It only looks at the
file system information, not at the file.

If you do a simple "touch foo.c", then make will compile foo.c again, not
knowing that it didn't change at all. Also, if you change a comment, or
rename a #define'd symbol, etc.  ccache won't. It knows that nothing has
changed. Sounds dangerous? Isn't.  :-)



> So would I see a worthwhile reduction in compile time?

Mostly, yes. Not always. In quite rare cases it can even be slower.



> Or indeed *should* I be doing 'make clean'? 

Shouldn't be necessary, but is sometimes safer, especially if you want
to erase information that {aclocal,auto{header,make,conf},configure}
cached. Sometimes I do even execute "cvs-clean" from KDE's cvs. It
removes everything that is not from cvs, almost like "cvs co".



> Secondly, if you've got a moment, can you tell how big the ccache cache gets, 

  $ du -sh ~/.ccache/
  408M    /home/m/.ccache


  $ ccache -s
  cache hit                          10195
  cache miss                          4488
  called for link                      513
  compile failed                       164
  preprocessor error                    82
  not a C/C++ file                     294
  autoconf compile/link               2846
  unsupported compiler option           68
  no input file                        444
  files in cache                      8976
  cache size                         404.9 Mbytes
  max cache size                     976.6 Mbytes


You can define the maximum cache size:

  $ ccache -h
  ccache, a compiler cache. Version 2.2
  Copyright Andrew Tridgell, 2002
  
  Usage:
          ccache [options]
          ccache compiler [compile options]
          compiler [compile options]    (via symbolic link)
  
  Options:
  -s                      show statistics summary
  -z                      zero statistics
  -c                      run a cache cleanup
  -C                      clear the cache completely
  -F <maxfiles>           set maximum files in cache
  -M <maxsize>            set maximum size of cache (use G, M or K)
  -h                      this help page
  -V                      print version number



> and give us an idea of the compile times on your hardware?

See above.

I don't say that ccache is the best thing since sliced bread, but
it has saved me a lot of time and never caused any problem.
To speed up the buliding process, you can also make plib's
and simgear's header files and static libraries links from
/usr/local/include and /usr/local/lib to their places in the builddir.
You don't need to install them after every change then, and can
so avoid to change the modification times of all the unchanged
files. Makes "make" less busy without ccache.

m.



[1] formal/polite: "Grüß Gott!"
[2] informal greeting in Austria and Southern German; Yes, it's Latin! :-)

_______________________________________________
Flightgear-users mailing list
Flightgear-users@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic