- Install distcc on both client and server(s)
- Configure distcc on both sides
- Configure Firewall on server(s) to allow incoming distcc traffic
- Build, build, build!
- Monitoring
Before we can go ahead with above, we need to install Linux VMs (I used VirtualBox) on the desktop since its running Windows. I created two Linux (Fedora 13, 64-bit) VMs where Linux Kernel compilation can be offloaded. Each VM was assigned 1G of memory and 2 vCPUs each (a single 4 vCPU VM was quite unstable). In general, you need to have both client and server with the same platform (32/64-bit) and the same compiler versions otherwise you can run into weird compiler/linker errors or even worse, undetectable errors!
Install distcc
sudo yum install distcc distcc-serverNow create these symlinks in a separate folder (e.g. ~/distcc/):
mkdir ~/distcc; cd ~/distcc ln -s /usr/bin/distcc gcc ln -s /usr/bin/distcc g++ ln -s /usr/bin/distcc c++
NOTE: do not create these symlinks such that they take precedence over your actual compilers, otherwise it will try to offload all kinds compilation you do on the client. In general, its not useful to offload very small compilations.
Configure distcc
Client side configuration:
Available servers needs to be listed in ~/.distcc/hosts file. On my laptop, it looks like this:
192.168.1.10,lzo, 192.168.1.11,lzo
Where 192.168.1.{10,11} are IPs of Linux VMs running on my desktop. The ‘lzo’ option tells distcc to compress object files as they are transferred over the network. This slightly increases CPU usage on both client and server but is useful if you have a low bandwidth network. This configuration completely offloads compilation to server. In case you want to local machine to also participate in compilation, change above to:
localhost, 192.168.1.10,lzo, 192.168.1.11,lzo
NOTE: do not use local IP address instead of term ‘localhost’ in this configuration file, otherwise distcc will incur network overhead even for local part of compilation. But if ’localhost’ is used, local part of compilation will have negligible overhead due to distcc.
As another example, you may want to restrict usage of local machine, so it can remain cool and most of the work is done by other servers:
localhost, 192.168.1.10,lzo, 192.168.1.11,lzo
Server side configuration:
USER=ngupta OPTIONS="--jobs 4 --allow 192.168.1.0/24 --port 3632 --log-file=/tmp/distccd.log"
Now, start the distcc server with:
service distccd start
Or, manually with:
distccd --daemon --user ngupta --jobs 4 --allow 192.168.1.0/24 --port 3632 --log-file=/tmp/distccd.log
Of course, you need to change the user. Now, verify that it started successfully with:
ps awwx | grep distcc
Configure Firewall
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3632 -j ACCEPT
Build, Build, Build!
All set now, its time to build! Now, for whatever compilation you want to distribute using distcc, issue build like this:PATH=$HOME/distcc:$PATH make –j8
This PATH prefix makes sure that those distcc symlinks get priority over the real compiler. This also gives us the control to use or avoid distcc easily – just don’t use PATH prefix as above and you will fall back to local compiler.
The distcc man page specifies that number of threads (make –j parameter) should normally be set to twice the number of available CPUs to cover for threads blocked on network I/O.
In my case, I have 2 VMs each with 2vCPUs, so total of 4 CPUs. Sometimes, I also add ‘localhost’ to distcc server list, so I can use 2 cores on my laptop too. With a total of 6 cores, my Linux kernel build time (with default Fedora 13 config) came down from over an hour to just 20 mins!
Monitoring
Figure: distccmon-gnome continuously showing distcc status during Linux kernel compile.
Happy Building! :)

