Last.FM: Recently listened

Saturday, February 10, 2007

Speeding up your compiler


I recently played around with ccache. This tool caches compiled C/C++ object files. Whenever you recompile a file, it checks whether the corresponding object file is in the cache and the compiler run may be saved.

You may ask, why we need this tool although we already have build systems that determine, when files need to be recompiled. The answer is, that build systems make their decisions upon file modification times and the existence of an older object. If the object is missing - for instance because you ran "make cleanall", make will trigger a rebuild. ccache however takes a preprocessed file and matches its checksum with the one it has cached. If both match, the cached object file is used and you save the time you'd otherwise need for running the compiler.

My benchmarks took place in our L4 environment - I compiled some applications without their objects being cached. Then, I ran "make cleanall" and started the build again, this time with caching enabled. The (reasonable) speedups are shown in the picture. We can see two things:
  • C++ (Dice, C++ small) builds are sped up more than C builds (the rest). This is because compiling a C++ file typically takes much more time which is then saved by ccache.
  • Large builds (L4Linux, Dice) are sped up more than small ones (cUnit, ...), because they include more compiler runs.

1 comment:

Anonymous said...

.. interessant aber darüber haben wir beide bereits gesprochen :D ..

Grüße

Bitti