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 10.1.1.1

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

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
10.1.1.2

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 :
STARTDISTCC="true"
ALLOWEDNETS="127.0.0.1 10.1.1.1/24"
LISTENER="10.1.1.2"
ZEROCONF="false"

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 http://kernel.org 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

8 comments:

  1. I have read your blog its very attractive and impressive. I like it your blog.
    Linux Training on RHEL 7

    ReplyDelete
  2. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.
    Linux Training Institute in India | Linux Training in India

    ReplyDelete
  3. Nice blog. Explained well. I have suggested to my friends to go through this blog. Very nice explanation. Thank you for sharing this useful information.
    If you want to learn linux course in online, please visit below site
    linux Online Training, linux course, linux online training in kurnool, linux online training in hyderabad, linux online training in bangalore, online courses, online learning, online education, trending courses, best career courses

    ReplyDelete
  4. Its a wonderful post and very helpful, thanks for all this information.
    Linux Training institute in Noida

    ReplyDelete