Slashdot Mirror


Optimizing distcc

IceFox writes "Having fallen in love with distcc and its ability to speed up compiling (insert anyone who compiles like Gentoo users or Linux developers). I recently got the chance to dive deeper into distcc. By itself distcc will decrease your build times, but did you know that if you tweak a few things you can get a whole lot better compile times? Through a lot of trial and error, tips from others, profiling, testing and just playing around with distcc, I have put together a nice big article. It shows how developers can get a bigger bang for their buck out of their old computers and distcc with just a few changes."

29 of 201 comments (clear)

  1. strlen by Anonymous Coward · · Score: 5, Funny

    Yep, root of all evil. strlen. Fix strings and you'll fix everything.

  2. Wow... by JoeLinux · · Score: 5, Funny

    For some reason, "Imagine a beowulf clusters using this" is on-topic.

    This is so weird.

    I must drink now.

    "I do NOT suffer from a mental condition. I'm enjoying every second of it."

  3. Website bit slow... by neonstz · · Score: 5, Funny

    ...maybe you should work on disthttpd next?

  4. Nice big article by wildzeke · · Score: 5, Funny

    By the time I read the article, my kdelibs was compiled.

  5. /.-ed already? by Lord+of+Ironhand · · Score: 4, Funny

    Looks like that server won't be doing much compiling soon...

  6. anal retentive admin by maxbang · · Score: 3, Funny

    From the article:

    I even found different colored cable for the different areas of my cube.

    I wonder if he also sealed the empty packaging, waste paper, and dead hardware in neat little foil packets before disposing of them in the proper receptacle, which, of course, sits right next to the cozy for his server. ;)

    --
    I also reply below your current threshold.
  7. ccache by Lord+of+Ironhand · · Score: 4, Interesting

    ccache is also nice for optimizing compiling. He probably mentioned it in the article, but since it seems /.-ed I wouldn't know... and by the time you've got both distcc and ccache running the article might be available again so you can read if you did it the right way :-)

  8. Copy of my article... by IceFox · · Score: 4, Redundant
    poor web server... I thought it could handle it...

    distcc optimizations - March 30th 2004

    and how to compile kdelibs from scratch in six minutes

    If you don't already know about distcc I recommend that you check it out. Distcc is a tool that sits between make and gcc sending compile jobs to other computers when free, thus distributing compiles and dramatically decreasing build times. Best of all it is very easy to set up.

    This, of course, leads to the fantastic idea that anyone can create their own little cluster or farm (as it is often referred to) out of their extra old computers that they have sitting about.

    Before getting started: In conjunction with distcc there is another tool called ccache, which is a caching pre-processor to C/C++ compilers, that I wont be discussing here. For all of the tests it was turned off to properly determine distcc's performance, but developers should also know about this tool and using it in conjunction for the best results and shortest compile times. There is a link to the homepage at the end of this article.

    Farm Groundwork and Setup

    As is the normal circle of life for computers in a corporate environment, I was recently lucky enough to go through a whole stack of computers before they were recycled. From the initial lot of forty or so computers I ended up with twelve desktop computers that ranged from 500MHz to 866MHz. The main limit for my choosing dealt with the fact that I only had room in my cube for fifteen computers. With that in mind I chose the computers with the best CPU's. Much of the ram was evened out so that almost all of the final twelve have 256MB. Fast computers with bad components had the bad parts swapped out for good components from the slower machines. Each computer was setup to boot from the CD-ROM and not output errors when booting if there wasn't a keyboard/mouse/monitor. They were also set to turn on when connected to power.

    Having enough network administration experience to know better, I labeled all of the computers, the power cord and network cord that was attached to them. I even found different colored cable for the different areas of my cube. The first label specified the CPU speed and ram size so later when I was given faster computers, finding the slowest machine would be easy. The second label on each machine was the name of the machine, which was one of the many female characters from Shakespears plays. On the server side a dhcp server was set up to match each computer with their name and IP for easy diagnosis of problems down the line.

    For the operating system I used distccKNOPPIX. distccKNOPPIX is a very small Linux distribution that is 40MB in size and resides on a CD. It does little more then boot, gets the machine on line and then starts off the distcc demon. Because it didn't use the hard disk at all, preparation of the computers required little more than testing to make sure that they all booted off the CD and could get an IP.

    Initially, all twelve computers (plus the build master) were plugged into a hub and switch that I had borrowed from a friend. The build master is a 2.7Ghz Linux box with two network cards. The first network card pointed to the Internet and the second card pointed to the build network. This was done to reduce the network latency as much as possible by removing other network traffic. More on this later though.

    A note on power and noise, the computers all have on-board components. Any unnecessary pci cards that were found in the machines were removed. Because nothing is installed on the hard disks they were set to spin down shortly after the machines are turned on. (I debated just unplugging the hard disk, but wanted to leave the option for installation open for later.) After booting up and after the first compile when gcc is read off the CD the CD-ROM also spins down. With no extra components, no spinning CD-ROM or hard disk drives the noise and heat level in my cube really didn't change any that I c

    --
    Do you changes clothes while making the "chee-chee-cha-cha-choh" transformation sound?
  9. Distccd for cygwin by aberant · · Score: 5, Informative

    My life changed the day i found out i could get my super fast P4 Windows XP box to compile for my slow linux box. Distcc for cygwin is a miracle. check out the thread at Gentoo forums

  10. Martin Pool interview by Wise+Dragon · · Score: 5, Informative

    Martin Pool, the brains behind distcc, was interviewed by ZDNet yesterday. How timely.

    http://web.zdnet.com.au/builder/program/work/sto ry /0,2000034960,20283318-1,00.htm

  11. Mirror by Rufus211 · · Score: 4, Informative

    I feel like burning my new site in a bit =)

    http://hackish.org/~rufus/distcc.php.html

  12. behind the XCode curtain by pohl · · Score: 4, Insightful

    This is cool...I learned something on slashdot today. On a hunch I got a bash shell on my OSX box at home and typed "dist--", and lo there be distcc already installed and ready to go. That must be what they use for distributed builds in XCode

    --

    The "cue the foo posts in 3, 2, 1..." posts will commence with no subsequent foo posts in 3, 2, 1...

    1. Re:behind the XCode curtain by Anonymous Coward · · Score: 5, Informative

      Yup, look at the X code preferences for distributed builds. The cool part is they use Rendezvous to automatically find machines to send work. You can set your box to use these others and/or offer service to others. Also on dual processor boxes is will treat them as two machines and do two compiles at once.

      Anyway, you can see distcc running when you have X code enabled for distributed builds and running.

      --jim

    2. Re:behind the XCode curtain by jcr · · Score: 4, Interesting

      Yes, it is. This was described in the XCode session at WWDC last year.

      I had a project that took about 15 minutes to build on my Dual G4. I turned on distributed builds in XCode, and it dropped to 2 minutes. Turns out that about a dozen of my collegues on my subnet are running the same build of our developer tools as I am.

      distcc rocks.. Whoever thought it up should get the appropriate "special award for extreme cleverness."

      -jcr

      --
      The only title of honor that a tyrant can grant is "Enemy of the State."
  13. Re:Martin Pool interview - clickable link by Poisonous+Drool · · Score: 4, Informative
  14. Re:I wonder... by timeOday · · Score: 4, Insightful

    If he was only interested in helping himself he wouldn't have bothered with a nice writeup for all us to read.

  15. Re:I wonder... by Lord+of+Ironhand · · Score: 4, Insightful

    If everyone measured the value of his actions only by the time it will save him/herself, there probably wouldn't be much of a free software community these days.

  16. Or... You could do it properly. by Moderation+abuser · · Score: 4, Informative

    Install Sun Grid Engine[1] since it's free and now open source and then not only do you get qmake for distributed builds but you also get a general purpose distributed processing system. And hey! It even has the current buzzword "grid" in the title so your PHB will love you.

    [1] http://gridengine.sunsource.net/

    --
    Government of the people, by corporate executives, for corporate profits.
  17. Why wasn't a factorial experiment used? by alptraum · · Score: 4, Informative

    Sigh, another experiment that could have benefitted greatly from factorial experimentation. If your unfamiliar with DOE, here is a basic introduction courtesy of NIST:

    http://www.itl.nist.gov/div898/handbook/pri/sect io n1/pri11.htm

    It appears in this case we have a variety of factors and trying to, in this case, have a response of "elapsed time" for compilation and it is a minimization problem. Instead of looking at factors individually, a factorial DOE would have allowed interactions to be analyzed and to look for a global optima rather than just optimizing individual factors and then tossing them all together, it doesn't work that way a lot/most of the time.

    If the author of this article is present: Why wasn't a factorial experiment used?

    1. Re:Why wasn't a factorial experiment used? by DarkMan · · Score: 3, Interesting

      Probably because it wasn't needed. And secondly, factorial DOE isn't as good as your implying it to be.

      Factorial DOE is useful if you have multiple measurable, continious or quasi continous [0] factors, and want to optimise - particualry when there is some trade off. In this case, however, most of the variables that were altered were clearly discrete (This version of make, or that version of make, for example), or it was clear that the optimum was at an extreme (More CPU speed is always good, for example).

      So, the factors I can see that would be suitable to a factorial DOE is the number of machines in the farm. Except, each machine is different, so that's effectivly an n-dimensional set, with 2 options on each dimension, for n machines. If your going to do the stats, you'd want to do them properly, so no handwaving them all together there.

      Plus, this is a determanistic situation. There is no real need for empirical analysis - you can do it all from first principles, which would be much more efficent, I think. And, indeed, that's what the author did - by looking at the theoretical background of it all, to use different makes and so on, to optimise.

      Finally, if you think that a factorial DOE will get you a global optimum solution, then your sadly mistaken. It's a good procedure for optimising, and it can avoid some local minima - but it's not guarenteed to find a global minima. The only guarenteed method I'm aware of is a synthetic annealing - and if you've got a faster method, I, and a large number of people doing numerical caluclations, would love to hear it.

      Oh, and the aim here was _not_ to find a global minima. It was to get something that was good enough. Trying for better than that is wasted effort.

      [0] For example, the set of integers, from 0 to 1000 is quasi continous. It's not really continous, but it's close enough for real purposes.

  18. Electric Cloud by Anonymous Coward · · Score: 3, Informative

    Yes, distcc is nice, but anyone with a really big build (say like hours long) must take a look at John Ousterhout's company Electric Cloud (yeah, John Ousterhout as in Tcl) here. They've built this replacement for gmake that runs the jobs in parallel but is smarter than distcc because it can break open all the recursive makes and run _everything_ in parallel and it works cross platform too. It's $$$ and not OSS :-) but designed to be ultrareliable.

  19. Re:Gentoo Impact(s) by y2dt · · Score: 5, Informative

    official gentoo distcc guide:
    http://www.gentoo.org/doc/en/distcc.xml

  20. Re:Article Text (Slashdotted Server) by Anonymous Coward · · Score: 3, Informative

    You must be new so I will explain it to you. There is a class of users that regularly Karma Whore and get their Karma maxed out and then proceed to burn Karma by posting things like goatse.cx at +1. They do this not only to annoy people but to prove the flaws with the moderation system. While this guy may not be one of those people it is important to not reward somebody for posting an article. Users can easily post the article anonymously and avoid this issue altogether.

  21. PHP article? by Vellmont · · Score: 3, Insightful

    If you knew you were going to be slashdotted, wouldn't you link to a static version of the article instead of one running a PHP script?

    --
    AccountKiller
  22. Missed the best point by MerlynEmrys67 · · Score: 4, Informative
    He completely ignored the usage of distcc and ccache together. The pair of applications make for a huge win.

    There are some problems though - which do you do first ccache or distcc (answer on my benchmarks is ccache - if it isn't in the cache send it on the network) how fast is your "build" machine - this is critical. The build machine is resonsible for preprocessing the file, checking if it is in the cache and then sending it out to be turned into an object. Especially when you interact the results of ccache (which most of your builds are just the same file over and over - very few "changed" files) and distcc - most of your time is spent in the first pass compiler.

    In our environment we had boatloads of dual XEON machines around - they made wonderful build machines, and it didn't hurt that we connected them with Gig Ethernet either. Did wonders for our build times.

    Over all distcc and ccache are wonderful tools that should be in every large compile environment - making compiles that used to take days take simple minutes. But you want to make sure that the dependancy between ccache and distcc work optimally in your environment.

    --
    I have mod points and I am not afraid to use them
    1. Re:Missed the best point by IceFox · · Score: 3, Insightful

      In the first paragraph I mention that you should use it and be familiar with it. Assuming that you already do use it, then the rest of the article applies about how you can improve a certain portion of it (distcc). You don't ignore all the books on optimizing C code just because there are plenty of algorithm books do you?

      -Benjamin Meyer

      --
      Do you changes clothes while making the "chee-chee-cha-cha-choh" transformation sound?
  23. Recursive Make Considered Harmful by JWhitlock · · Score: 5, Informative
    There was an interesting paper by Peter Miller in 1997 called "Recursive Make Considered Harmful". It makes a good case for why recursive make is a bad idea, slowing down compile times and clouding dependancies. Benjamin Meyer has proved the point again, with his use of unsermake - if you generate a non-recursive make, then distributed compiles are twice as fast.

    Unfortunately, the makefile creator most people use, automake, creates only recursive makefiles. Maybe a replacement like unsermake will get automake developers thinking about radical changes. I wouldn't mind seeing M4 go away, for one.

    1. Re:Recursive Make Considered Harmful by ewhac · · Score: 3, Interesting

      Seconded.

      When I was at Be, Inc. (RIP), one of our engineers, motivated largely by the above-referenced article, converted our entire build environment to a non-recursive structure using gmake. The result was a large speedup, as well as more effective use of multiple processors (which BeOS utilized very well). gmake would grovel over the build tree for a minute or two, then launch build commands in very quick succession. 'Twas great.

      Schwab

  24. Re:distcc isn't so great by KFK2 · · Score: 3, Informative

    Well.. here goes a couple of mod points that I spent.. but I'd thought I'd chime in..

    My friend recently had the same thing happen, and the conclusion we came to was that the compiler versions were different on the distcc servers (3.2.2) versus the client (3.2.3).. and the preprocessed code being sent off had syntax erorrs or something of the like when it was sent off (something to do with one of the new options in the latest gcc). I don't recall exactly what option it was or what package(s) were failing... but I do know that somewhere there was an 'if gcc-version 3.2.3 then add some options to CFLAGS' (maybe /etc/make.globals? or make.conf).

    This is one of the biggest things I have found with distcc.. compiler versions have to be pretty similar.. usually even the incremental version changes affect the compiles..

    I've not had any problems with using distcc, both with compiling Gentoo packages, along with my own projects..

    Kenny