As someone who is always looking to maximize performance and efficiency from my computers, I was delighted to have stumbled upon a program named Distcc a while back. According to their website distcc is a “fast, free distributed c/c++ compiler.”Distcc is brought to you by the same people who created and maintain Samba, the open-source program that allows Unix-like operating systems to act as Windows file and print servers. Distcc is small, simple to use, and works on a variety of Operating Systems. Distcc can speed up compilations in a near linear fashion. For example, tripling the number of computers in the build will nearly triple the speed of the build. It even includes a Gnome-based graphical monitor that will show you which file is being compiled on which machine. I will take the remainder of this article to cover installation and some basic uses of this amazing free software.
Installation and Configuration
Distcc provides binaries as well as source code for many available versions of Unix and Linux. Binaries are provide in RPM and DEB format for easy installation for both Redhat and Debian based systems. Installation from source code is simple as well with the traditional ./configure, make, and make install commands. Each server machine will need to run the distcc daemon. Typing the command distccd is all that needs to be done. Each client machine will need to know the names of the servers. This is done by exporting the environment variable DISTCC_HOSTS. This can be done by typing export DISTCC_HOSTS=”localhost server1 server2 server3′ at a terminal prompt. This can be made permanent by placing the same line in a file that is read at startup (/etc/profile or .bashrc for example).
To test the performance of distcc, I decided to compile two of the most popular open-source projects. The first and most important is the Linux kernel itself. The second is Wine, the open-source project that allows some windows applications to be run on Linux. All compilations were done in run level 3 (network services running without a graphical user interface). I timed all the results by preceding the compilation commands with the time command. The number reported is the real time between invocation and termination of the compile. The test machines were both running RedHat Linux 9.0. One machine was a 900MHz AMD Duron with a 5400RPM hard drive and 256Mb RAM. The other was a 1.2GHz Duron with a 7200RPM hard drive and 256Mb of RAM.
To test the compilation of the Linux kernel, I first downloaded kernel 2.4.22 from kernel.org. I then unpacked the archived and ran through a standard configuration for my system. I then ran make BzImage without using distcc and timed the results:
9 minutes, 29.110 seconds
Next, I removed the kernel directory and rebooted the system. I then unpacked the archive once again and configured the kernel with the same options. This time I compiled the kernel with make -j8 bzImage CC=distcc. The results were impressive:
3 minutes 44.11 seconds
Using distcc gave a 61% performance increase. Let’s see what it can do for Wine.
I downloaded Wine-20031016.tar.gz from the download section of winehq.org. I unpacked the archive, ran the configure script, and then the make command. The results without distcc:
32 minutes 15.580 seconds
I once again removed the archive and rebooted the system. I unpacked the archive and issued the command make -j8 CC=distcc. Once again the results were impressive:
11 minutes 57.344 seconds
This time we see 63% improvement in performance.
Distcc is one of those little useful programs that you may have never heard about or explored. As you can see, it is a breeze to set up and can save a tremendous amount of time if you have a LAN and need to compile a program from source. With the emergence of source based distributions such as Gentoo, there has never been a better time to have a tool like Distcc at your disposal. More information can be found at distcc.samba.org.
About the Author
Paul Virijevich has been studying and learning open-source technologies including GNU/Linux since 1996.