Slashdot Mirror


Distributed Compilation, a Programmer's Delight

cyberpead writes in with a Developerworks article on the open source tool options that can help speed up your build process by distributing the process across multiple machines in a local area network.

60 comments

  1. What about Excuse #1? by dsginter · · Score: 4, Funny
    --
    More
    1. Re:What about Excuse #1? by Andr+T. · · Score: 1

      If you get many slow machines and a slow network, it'll actually take longer to compile - and you'll still be able to happily say that.

      --

      Any life is made up of a single moment, the moment in which a man finds out, once and for all, who he is.

    2. Re:What about Excuse #1? by debatem1 · · Score: 1

      distcc scales pretty close to linearly. You'd have to have not-very-many slow machines and a slow network.

    3. Re:What about Excuse #1? by networkconsultant · · Score: 1

      So if I build 4 machines with quad cores and configure dist cc does that mean I`ll finally be able to build open office from source on gentoo?

    4. Re:What about Excuse #1? by Andr+T. · · Score: 1

      Can you use the internet? Imagine using a p2p network... you compile the files and give the .obj back to the linker. This could take ages.

      --

      Any life is made up of a single moment, the moment in which a man finds out, once and for all, who he is.

    5. Re:What about Excuse #1? by cbreaker · · Score: 1

      Blah blah blah Gentoo blah blah compiling forever blah blah punchline.

      When I first used Gentoo several years ago it was with a 950Mhz Athlon CPU and it wasn't too bad.

      Now, with quad-core CPU's becomming the norm even in Desktop machines, the compiling thing is even less of an issue.

      I was able to run software on Gentoo that I could never get to run well together on any other distribution. You can almost always get the latest and greatest versions of everything with Gentoo. With Kernels taking almost no time to compile these days, the source distribution excuse just keeps getting weaker and weaker.

      The main problem with Gentoo was it's moving target when it came to core system tools. They'd upgrade the ebuild system and it could sometimes hose your system. I haven't used Gentoo in a couple years because of it, but I'd be willing to give it another shot eventually.

      --
      - It's not the Macs I hate. It's Digg users. -
    6. Re:What about Excuse #1? by khellendros1984 · · Score: 2, Informative

      That was my problem. Broken ebuilds. Conflicting requirement lists that the updater script wasn't any good at working out. Gentoo made me run back to Slackware for a while, and eventually to Ubuntu (about 2-3 years ago, to see what the buzz was about).

      --
      It is pitch black. You are likely to be eaten by a grue.
    7. Re:What about Excuse #1? by networkconsultant · · Score: 1

      Abviously you`ve never tried to compile Open Office. ;) (Even on a powerful system it takes days. ).

    8. Re:What about Excuse #1? by Joe_Sextus · · Score: 1

      I compiled Open Office 3 last Monday on a 2.0 GHz Core 2 Duo with 1 GB of RAM and no swap in 2 hours and 45 minutes. That's my best time yet.

    9. Re:What about Excuse #1? by heson · · Score: 1

      I like Icecream, dunno why it feels better than distcc, maybe the bugs are fewer.

    10. Re:What about Excuse #1? by Thiez · · Score: 3, Insightful

      That would allow for people to inject malware, wouldn't it?

      To compile:

      void printhello() {
        printf("Hello world!\n");
      }

      evil bastard changes to:

      void printhello() {
        {
         
        }
        printf("Hello world\n");
      }

      Since the most practical way to spot the evil binary would be to compile the code yourself and compare, that sort of defeats the purpose of having someone else compile it. I guess you could have many random people compile the same piece of source-code and then compare all produced code, but that makes the whole thing rather complicated.
      Also, the p2p thing would only be useful for open source, as I doubt it would be smart for people trying to produce some closed source product to send their source to a p2p network that may or may not store everything.
      And this is all assuming the delays introduced by sending all this stuff over the internet are not so large that compiling locally is faster or almost as fast.

      It's probably best to compile your stuff on your lan, on machines that are close, and that can be trusted.

    11. Re:What about Excuse #1? by ORBAT · · Score: 2, Insightful

      If by powerful system you mean steam-powered Analytical Engine, yes, it'll take days.

      The longest OpenOffice compile I've ever done was something around 5 hours, and that was with the system doing other stuff on the side. Distcc et al reduce the compile time to around 2h.

    12. Re:What about Excuse #1? by nurb432 · · Score: 1

      If you are that paranoid only use a farm where you have control over all the machines.

      --
      ---- Booth was a patriot ----
    13. Re:What about Excuse #1? by cbreaker · · Score: 1

      Well, not days, hours. Historically, Gentoo has provided some binary packages for software that takes an undue amount of time to compile and won't affect the rest of the system if compiled with generic options.

      If I recall correctly, OpenOffice was one such package.

      Gentoo isn't that masochistic.

      --
      - It's not the Macs I hate. It's Digg users. -
    14. Re:What about Excuse #1? by jerep · · Score: 1

      Compile times? I'm using D you insensitive clod.

  2. Bulk building is more effective by TheThiefMaster · · Score: 3, Informative

    Due to a strange quirk in the way compilers are designed, it's (MUCH) faster to build a dozen files that include every file in your project than to build thousands of files.

    Once build times are down to 5 - 15 minutes you don't need distributed compiling. The link step is typically the most expensive anyway, so distributed compiling doesn't get you much.

    1. Re:Bulk building is more effective by Anonymous Coward · · Score: 0

      From my experience, the link step is way less expensive them the actual compilation. It takes me ~10 minutes to compile all my source files and less than a minute to perform the linking.

    2. Re:Bulk building is more effective by Anonymous Coward · · Score: 0

      you are not the typical case

    3. Re:Bulk building is more effective by loonycyborg · · Score: 1

      Linking is much slower with debug symbols enabled than without, but still not slow enough to be significant.

    4. Re:Bulk building is more effective by TheThiefMaster · · Score: 1

      Or link-time code generation if you have that level of optimization turned on.

    5. Re:Bulk building is more effective by swillden · · Score: 1

      Due to a strange quirk in the way compilers are designed, it's (MUCH) faster to build a dozen files that include every file in your project than to build thousands of files.

      True of Visual C++, not true of any other compiler I'm familiar with.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    6. Re:Bulk building is more effective by jgrahn · · Score: 1

      Due to a strange quirk in the way compilers are designed, it's (MUCH) faster to build a dozen files that include every file in your project than to build thousands of files. Once build times are down to 5 - 15 minutes you don't need distributed compiling.

      But your code will be harder to understand. You're giving up a lot of tools, like static globals in C and anonymous namespaces in C++.

      Every time I have encountered painfully long compile times, the cause has been sloppiness. Usually, the direct cause is that noone has maintained the Makefile, so there's an untrusted heap of recursive Makefiles which only work if you do a "make clean" first. And which don't work with Gnu make's -j flag.

      Throwing hardware at such a problem would feel like running Bubble Sort on a supercomputer.

      The link step is typically the most expensive anyway, so distributed compiling doesn't get you much.

      What linker are you using, and how do you use it? For Gnu ld, the work seems to be mostly file I/O. I have seen one insane linker which took 15 minutes and 300 MB of virtual memory to link something which ended up a few megabytes of object code, but I hope that's not typical.

  3. Very Cool by dintech · · Score: 1

    Imagine a beowolf cluster for those.

  4. Is this new? by daveewart · · Score: 2, Insightful

    Article summary: use 'make -j', 'distcc' and 'ccache' or something combination of these. These utilities are well known and widely used already, no?

    --
    "If you think the problem is bad now, just wait until we've solved it." --- Arthur Kasspe
    1. Re:Is this new? by cbreaker · · Score: 1

      Yea. I used to use distcc a lot about five years ago. It doesn't help with all compile functions but it can help if you're compiling something big like X11 or KDE.

      --
      - It's not the Macs I hate. It's Digg users. -
    2. Re:Is this new? by Anonymous Coward · · Score: 0

      No, we're still discovering it. And worse recreating much of it since we don't know it already exists.

    3. Re:Is this new? by Anonymous Coward · · Score: 0

      If you want something new, look at distmake.

      It's Gnu Make, extended to run jobs on multiple hosts. It's very fast.

    4. Re:Is this new? by Slashdot+Parent · · Score: 1

      Yeah, I was wondering the same thing. distcc and ccache has been a staple of Gentoo users since forever.

      --
      They don't grade fathers, but if your daughter's a stripper, you fucked up. --Chris Rock
  5. Minor error by pipatron · · Score: 4, Informative

    There's a minor error in the article, which claims that your servers need access to the source. distcc was designed to not need this.

    --
    c++; /* this makes c bigger but returns the old value */
    1. Re:Minor error by SleptThroughClass · · Score: 2, Insightful

      There's a minor error in the article, which claims that your servers need access to the source. distcc was designed to not need this.

      That implies you read the article, but that can't be the case.

    2. Re:Minor error by cbreaker · · Score: 2, Informative

      I read it too, and it's true - they DO say all of the machines need access to the source which they do not.

      Maybe there's some special cases, but I've never had to have a shared source repository in order to use distcc.

      They also say the machines need to be exactly the same configuration, and they do elaborate on that a little bit, but it's not strictly true. Depending on the source you're compiling, you might only need to just have the same major version of GCC.

      --
      - It's not the Macs I hate. It's Digg users. -
    3. Re:Minor error by Anonymous Coward · · Score: 0

      False - distcc does require the same version of the OS. I've tried using distcc to spread compilation of the kernel across a ubuntu & redhat machine that I have (both x64), and it refused.

      It depends upon how the OS identifies itself. Also, I'd recommend using the avahi version of distcc (Fedora 9 comes with it - I believe it finally made it into Intrepid) which allows for automatically detecting servers on your network.

    4. Re:Minor error by pipatron · · Score: 2, Informative

      False - I regularly use windows as a host for example, running distcc in cygwin. The only thing you have to make sure is that the compiler called by distcc will create object files for the client system. You can have a renderfarm of sparcs generating code for your ARM router if you like.

      --
      c++; /* this makes c bigger but returns the old value */
    5. Re:Minor error by DogAlmity · · Score: 1

      False False - distcc does not require the same version of the OS. I spread compilation across four machines. The host was Gentoo, one of the other machines was Gentoo, and the other two were machines I just stuck the latest Knoppix CD in.

      Gentoo machines were using gcc 4.1.x i586, Knoppix had gcc 4.1.x i386. All 32-bit. The resulting build was lightning fast and error-free. This was an app not the kernel.

    6. Re:Minor error by Anonymous Coward · · Score: 0

      False - distcc doesn't give a fuck what OS you're running it on. Your OS, on the contrary, may.

    7. Re:Minor error by cbreaker · · Score: 2, Insightful

      "False - distcc does require the same version of the OS. I've tried using distcc to spread compilation of the kernel across a ubuntu & redhat machine that I have (both x64), and it refused."

      You didn't read my post or you have low comprehension skills. I said "Depending on the source you're compiling."

      A Kernel build might require specific libraries to be the same version. Building Firefox might not. Some apps you can build on Linux and use a cygwin box running distcc to help. Others you cannot.

      It's not a RULE. It depends the the source. That's what I said. Then again you might have actually realized that and that's why you posted AC.

      --
      - It's not the Macs I hate. It's Digg users. -
  6. In other news by adonoman · · Score: 4, Funny

    Slashdot readership plummets to an all-time low as programmers actually have to work.

    1. Re:In other news by tcopeland · · Score: 1

      > Slashdot readership plummets to an all-time low as programmers actually have to work.
      Not at Sun, though... yikes.

    2. Re:In other news by adonoman · · Score: 1

      Ouch!

  7. raggle fraggle by TheRealMindChild · · Score: 2, Funny

    Sky rockets in flight... distcc delight......
    distcc deliiiiiiiight.

    --

    "When life gives you lemons, don't make lemonade. Make life take the lemons back!" -- Cave Johnson
    1. Re:raggle fraggle by i.r.id10t · · Score: 1

      Thought thief!

      --
      Don't blame me, I voted for Kodos
  8. distcc has one fatal flaw by Anonymous Coward · · Score: 0

    It requires all preprocessing (-E option to gcc) to be done on one machine. This can frequently create such a big bottle neck (especially on C++ code) that it swamps any gain from the distributed obj compiling. The preprocessing takes so long that the rest of the machines are idle and waiting for jobs and you are also sending huge text files across the network. I know distcc supports compressing these files, but even that is done serially on the initial compile machine.
    distcc also is very flawed in a multiuser environment when it comes to fair distribution of jobs. You typically end up with one machine bogged down and the compiles actually end up taking longer than just doing everything locally.

    1. Re:distcc has one fatal flaw by TeknoHog · · Score: 3, Informative
      From man distcc:

      In pump mode, distcc runs the preprocessor remotely too. To do so, the preprocessor must have access to all the files that it would have accessed if had been running locally. In pump mode, therefore, distcc gathers all of the recursively included headers, except the ones that are default system headers, and sends them along with the source file to the compilation server.

      --
      Escher was the first MC and Giger invented the HR department.
  9. Preprocessing in C by Frans+Faase · · Score: 4, Informative

    I guess you are refering to the preprocessing step of C and C++ compilers, which was really a lame hack, I think. If you have a lot of include files, preprocessing produces large intermediate files, which contain a lot of overlapping code, that has to be compiled over and over again.

    Preprocessing should have been removed a long time ago, but nasty backwards compatability issue, it was never done. Other languages, such as Java and D, solve this problem in a much better way. Just as did TurboPascal with its TPU files in the late 1980's.

    1. Re:Preprocessing in C by Anonymous Coward · · Score: 0

      Actually, it's more about disk I/O than strictly preprocessing (though re-doing preprocessing over and over is awfully inefficient also).

      Imagine you have 500 CPP Files and they all include a tree of 10 - 100 header files.

      Compiling each CPP in turn requires 10 - 100 files read off the disk each time.

      Batching all the .CPPs in to a single file which also includes all 10 - 100 header files is orders of magnitude fewer reads and thus faster.

      I imagine there is probably a limit to how large of a project you can do this on (though we haven't hit it and we're 8k+ .CPPs and .Hs)

    2. Re:Preprocessing in C by Charan · · Score: 1

      Compiling each CPP in turn requires 10 - 100 files read off the disk each time.

      Modern operating systems get around this issue with a disk cache. In reality, 100 files will be read off the disk for the first compile, and the rest of the compiles will just access the cached copy in memory (unless memory is in short supply on your system).

    3. Re:Preprocessing in C by Anonymous Coward · · Score: 2, Informative

      It's not sufficient for large projects; disk I/O is still a very large overhead when compiling. Switching to a 'Unity' build scheme reduced compile times significantly (more-so than the distributed compile solution we used since it still had to read the files off disk multiple times in addition to sending them over the wire to multiple machines). .CPPs and .Hs make up about 110mb on our project.

    4. Re:Preprocessing in C by Anonymous Coward · · Score: 0

      Addendum: When we were doing our profiling, that 110mb transferred in to 10's of GB of data being read from and written to the disk in a single compile.

  10. Wrong stuff... by Anonymous Coward · · Score: 0

    The article says each machine involved in a distcc compile must have access to all source files. This is not true: distcc runs the pre-processing stage, where all the header files are included, before sending the processed file to the machine(s) for compilation. They do not need the source and not even the includes/libs the software links against. All that happens on the central machine.

  11. We can't take TFA's author's adivce! by idontgno · · Score: 1

    He's using TCSH! That's BAD FOR YOU!

    Ok, enough offtopic. This is actually pretty cool, considering our development environment is clusters and clusters of IBM P-Series LPARS, and our codebase is (A) disgustingly huge, and (B) actually pretty amenable to parallelized make.

    FINALLY, I can justify to my boss that browsing /. is research! (Now if I could just make a good case for 4chan...)

    --
    Welcome to the Panopticon. Used to be a prison, now it's your home.
  12. SMEs by hachete · · Score: 2

    The reason for a lot of build machines in the rack may not be horsepower but rather you need x different machine versions, or a certain build only builds on a certain machine because of licence restrictions or you may only have one windows box with the Japanese character set installed because it causes so many problems that multiplying the problems just isn't worth it and so on and so forth. Building across n number of the same machine version just isn't worth the work IMO. Just get a bigger machine and save on the machine maintenance.

    So the real benefit of distcc might be parallel compilation; I see a big future for this, particularly with the chipsets becoming commonplace. Once upon a time, I would not countenance a dual-chip machine in the rack because of the indeterminate mayhem it would sometimes cause to a random piece of code deep in the bowels. Those problems are well gone.

    Umm. I wonder how this plays out how with VMWARE? A distributed compiler smart enough to use the (correct) local compiler across a varied build set would be worth having ...

    --
    Patriotism is a virtue of the vicious
  13. WFC by Anonymous Coward · · Score: 0

    ...snooze...

  14. No distcc hints... by GenP · · Score: 1

    Dang, no info on creating uniform toolchains for each distcc arch. IncrediBuild at work is really good about that, though it has the distinct advantage of being able to just shoot a single executable over the wire if the remote end needs it.

  15. Icecream. by Sir_Lewk · · Score: 2, Interesting
    If you are interested in distributed compiling, you may want to check out icecream. http://en.opensuse.org/Icecream

    It's similar to distcc, but with some notable benefits.

    --
    "linux is just DOS with a UNIX like syntax" -- Galactic Dominator (944134)
  16. 'native' breaks distcc by Progman3K · · Score: 1

    If you want to distribute compilations, you must not use the 'native' gcc option, it will cause the compiler instances to emit objects in the native format of the compiler invoked and your compilation hosts may not all be identical.

    --
    I don't know the meaning of the word 'don't' - J
  17. Only on Apollo by Anonymous Coward · · Score: 0

    The only place this ever worked well, and transparently, was when using DSEE on Apollo.

    But then, it could also reuse .o files already in place from some other developer's compilation. It was rigorous enough to know the dependencies leading to that .o were identical, including environment issues.

  18. Dilbert version is funnier by istartedi · · Score: 1

    Tried to find it, but couldn't. It goes something like this:

    Panel 1: PHB, walking by Dilbert's cube: Dilbert, why aren't you working?

    Panel 2: Dilbert: My programs are compiling.

    Panel 3: PHB, sitting back at his desk by himself, thought bubble: I wonder if my programs compile.

    --
    For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
  19. I've found a better solution altogether by Tablizer · · Score: 1

    It's called an "interpreter".

    (Cue flamewar in 3...2...1...