Compile time, over time

I’ve been getting the impression for a while that the GCC C Compiler has been getting slower over time at compiling. To check whether this was in fact true, I timed building a popular software package (emacs) with each major version of the compiler that I could get ahold of. I also added in a few other compilers, for reference.

For the benchmark, I built the temacs part of the GNU emacs distribution (version 22.3). System used is a 1.6GHZ AMD Sempron, 512MB RAM, running Fedora 13.

The compilers used were:

  • gcc – The GNU C Compiler – the standard system compiler on virtually all Linux distributions.
  • llvm – Low-Level Virtual Machine – a new(ish) compiler being developed by Apple and the University of Illinois. It uses the new clang front-end.
  • icc – The Intel C++ Compiler – Intel’s own compiler, known for aggressive optimizations.
  • pcc – The Portable C Compiler – a modernized version of the original BSD Unix system compiler.

Continue reading

Using distcc to speed up Linux builds

distcc is a clever little program that allows you to distribute compilations to many machines, across the network. If you have a bunch of machines running the same operating systems and compilers, it’s quite easy to use: start the daemon on all the machines you wish to serve compilation jobs to, tell the host doing the compiling to use distcc rather than gcc or g++ and compile away!

The problem comes about when the systems aren’t running the same OS. For example: I have an older Linux laptop that I occasionally build things on, but a much faster MacOS X desktop machine. The solution in this case is a cross-compiler. A full-fledged cross-compiler is a complicated thing and requires an obnoxious amount of preparation, but for the purposes of distcc, one can avoid most of the headache.

Continue reading

The 3n + 1 problem

The 3n + 1 problem is deceptively simple. Consider a function f(n) and a sequence ai where:

f(n) = 3n+1 where n is odd
  n/2 where n is even

ai = n where i = 0
  f(ai-1) where i > 1

The Collatz conjecture states that ai will become 1 for some i regardless of what value of n is chosen initially. It remains to date a conjecture as there is no proof for it, but there is no counterexample either.

Continue reading