|
|
...making Linux just a little more fun! Speed Compiling with Distcc
IntroductionWhen was the last time you compiled a linux kernel? Yesterday? Last week? Five minutes ago? On a 486? I don't remember either. Remember how long it took? I remember that. Too long. Too damn long. Now why would I want to compile the latest kernel on a 486? Ordinarily, I wouldn't. But with the tragic death of my main computer I was forced to move my computing needs to an old 486 someone had given me. I had been using this one as a NTP time server for my home network. Suffice it to say, what was on the NTP server wasn't the latest and the greatest. The other computer on the network wasn't much of an improvement over the 486. (A foundling laptop with a miniscule hard drive.) Well I was screwed because I needed my Emacs. So I pulled the drive from the dead computer and hooked it up to the 486. It worked flawlessly, which is a testament to the Linux kernel and GNU Software quality and efficiency. I didn't really know what to expect regarding response and the general feel of the environment, but in console mode I noticed no real difference. The X window system even worked fine, albeit slow on the start-up. Now, there was no way the GIMP or Mozilla was going to run with any kind of usability, but I could use Emacs and lynx or dillo without too many problems. But did I really want to sit through something that was going to take a few hours at least? Not really. I guess I could have washed dishes, mowed the lawn or watched TV but, hey, TV sucks. I'd rather watch a kernel compile. Enter the award-winning distcc, a distributed compiler front end for gcc, written by Martin Poole. DistccDistcc consists of two binary
programs:
The easiest way to demonstrate I'll show how to compile Minimum Requirements: Two compatible networked computers designated as a server and a client. The server:
Note: There are a couple of other programs produced by
These are monitor programs to show you what's happening during a
The client:
Building Standard Operating Procedure: $ tar -jxvf distcc*(use j flag not z with tar, distcc is bzip2ed). $ cd distcc* $ ./configure $ time make(don't forget the time command).
Without
It took longer to run the configure script than it did to compile. Install the binaries: make install distcc and distccd should be in /usr/local/bin
For the client machine:
Transfer a copy of Now to use Make sure you are in the $ make clean This will clean out all the crud leftover from the first compile. You won't need to run configure again. We need to spend a couple of minutes setting up for
1. Run the $ distccd --daemon It'll bitch about no 2. Set the You can use IP addresses or if your /etc/hosts file is set-up properly the hostnames of the computers. I have two computers at the moment: Set the variable (sh syntax, adjust for your shell): $ export DISTCC_HOSTS="mothra ghidra" or $ export DISTCC_HOSTS="192.168.1.2 192.168.1.3" Either way it doesn't matter. Recompile the code: $ time make -j4 CC=distcc Explaining the command line: time: should be obvious. make -j4: CC=distcc:
distcc compiled with distcc
real 6m38.089s
user 2m42.200s
sys 0m29.520s
Cut the time in half! You can't complain about that. The following shows times for some of my favorite programs compiled with
and without Remember, I'm compiling with a 486 without
Dillo Web Browser
The BASH Shell
This was the most amazing for me. This is 1/4 of the
non- Conclusion:
You can define the available compiler hosts in a $HOME/.distcc/hosts file. You can force For example, rather than having my poor little 486 desktop grind down
to an almost unusable state as More documentation is at the distcc web site. Oh, yeah - that kernel compile. How long did it take? I don't
know. I said screw it, I'll just stick with the stock kernel from my
Slackware install. Even with
A webpage is available here.
|
V. L. Simpson, after being unceremoniously (and rather rudely)
informed that GNU Emacs is not an operating system, has been
re-adjusted to a happy, regular life after many protracted
sessions with 'the doctor'.