Thursday, March 22, 2012

Distributed Kernel Compilation in Ubuntu

We are going to use "distcc" which is a distributed C/C++ compiler.

1. We have one host machine (Machine A) on which we have downloaded the latest linux kernel sources. The IP address of this machine is

We have one more machine (Machine B) which we are going to run the distributed compiler. The IP address of this machine is

Both the machines are running Ubuntu.

2. On Machine A do the following :

Install distcc :
$sudo apt-get install distcc

Add entry for Machine B in the '/etc/distcc/hosts' file. Comment out '+zeroconf' as given below since we are not going to use it :
# Add a list of hostnames in one line, seperated by spaces, here.
# +zeroconf

Check if the host is added :
$distcc --show-hosts

3. On Machine B do the following :

Install distcc :
$sudo apt-get install distcc

Edit the '/etc/default/distcc' file and set the following parameters :

Start the "distcc" service :
$sudo service distcc start

Now we are ready to start the distributed kernel compilation.

4. Download the latest linux kernel source from and extract it on Machine A. Setup the kernel .config file (refer this guide for more information). Now to start the distributed compilation and even time it :
$time make -j8 CC=distcc
This will start 8 threads and distribute the compilation between Machine A and Machine B

5. Test results :
kernel compilation using single machine :
real 50m55.498s
user 71m4.967s
sys 6m55.030s

kernel compilation using three machines:
real 28m21.146s
user 17m32.862s
sys 4m35.537s

No comments:

Post a Comment