A Distributed Front-end for GCC 195
format writes "distcc is a distributed front-end for GCC, meaning you can compile that big project across n number of machines and get it done almost n times as fast.
The machines don't have to be identical or be running the exact same GCC version, but having the same OS is helpful." With the advent of faster hardware, I can't complain about kernel compile times anymore, but larger source trees could definitely benefit from this.
Don't need the same version? (Score:1, Interesting)
Re:Don't need the same version? (Score:5, Informative)
distcc doesn't care. However, in some circumstances, particularly for C++, gcc object files compiled with one version of gcc are not compatible with those compiled by another. This is true even if they are built on the same machine.
It is usually best to make sure that every compiler name maps to a reasonably similar version on every machine. You can either make sure that gcc is the same everywhere, or use a version-qualified compiler name, such as gcc-3.2 or gcc-3.2-x86-linux.
So in other words, keep them close, especially for gcc versions that break backwards capability.
Re:Don't need the same version? (Score:1)
finds a compile node that uses the same compiler. Think of something like mozilla, that uses C and C++. gcc and c++ could invoke different compiler (at leat different versions).
GCC version (Score:5, Insightful)
Well, to some extent they probably do. If you're running GCC 3.2 on one, you wouldn't be able to run 3.0 on another because of binary incompatibility.
Re:GCC version (Score:2, Informative)
Regardless of the language, if some of the machines are running a different OS, or have a different architecture, they will have to do cross-compilation and things will get more complicated.
Colin Howell
binary incompatibility (Score:2)
Only true for C++ (Score:4, Informative)
Re:Only true for C++ (Score:1)
Re:Only true for C++ (Score:2)
> compatible with other GCC versions, even for C.
That's plain wrong. My GNOME 1 libraries are compiled by RedHat's gcc 2.96. All the GNOME 1 apps I have compiled myself are compiled using GCC 3.0, and they work just fine.
Maybe that "align" attribute can cause problems but it's disabled by default, and I have yet to see any desktop app using that flag by default to compile.
Re:Only true for C++ (Score:2)
Re:Only true for C++ (Score:2, Interesting)
And no, the answer is not to remove the alignment, as it speeds up array accesses by making the size of the struct a power of 2.
Source code (Score:4, Insightful)
Can you imagine code compiling or failing to compile randomly depending on which machine happens to compile it? Yikes! Debugging nightmare...
Re:Source code (Score:5, Insightful)
I wonder how much of a problem network bandwidth is in this system. With Condor, moving large datasets between machines is a problem. Object files can be pretty big and if you have a lot of them, you might risk pushing the compile bottleneck to the network. Even worse might be the link step, where all of the objects have to be visible to one machine (gcc doesn't have incremental linking yet, does it?).
Re:Source code (Score:2)
It turned out that the way I debugged it was to get login permission on the remote machines and run builds on the machines by hand. I later learned about a number of other switches I could have added to my condor submission script that would have logged stdout and stderr.
This actually has nothing to do with the kernel or header files. It's purely a glibc mismatch.
Re:GCC version (Score:2)
hmmm (Score:5, Funny)
Re:hmmm (Score:5, Informative)
In that case you might like to look at ccache [samba.org] which is a compiler cache for a single machine.
It will cache the compiler options for each source file and the resultant object file generated. I use a lot when I'm building packages for software - which require multiple compilations. It works very nicely - I'd love to see how well it would integrate with distcc....
Re:hmmm (Score:3, Insightful)
I recall that all of my lower powered machines were lucky to see a 6GB drive, letalone have 2-4GB to spare.
Now if only this was integrated with CVS (Score:1)
is its ability to "wink in" object files
from other developers' views. That means, if
one developer in the team has built a version
with a certain time stamp, that particular
object file never has to be built by anyone
else in the group unless some dependency changes. It would kick ass if CVS had that
capability.
Magnus.
Interesting approach (Score:5, Interesting)
Definitelly would make beowulf clusters interesting for compilation as well as hard core numerics (no joke intendend).
Re:Interesting approach (Score:3, Insightful)
Actually, you wouldn't need a Beowulf cluster at all - just a bunch of networked machines.
Re:Interesting approach (Score:1)
all the compilation node. neither distcc nor gecc (http://gecc.sf.net ) need this.
Re:Interesting approach (Score:2)
Not N (Score:5, Informative)
Just to clarify.
Re:Not N (Score:2, Funny)
YES! N! Re:Not N (Score:5, Informative)
You can almost never achevie a speed up of N. You can acheive S(N) = (1)/ (T(1)*alpha+((1-alpha)*T(1)) / N+T0) Where
T(1) is the time it takes to run the task with 1 computer, alpha is the part of the task that cannot be parallelised (as in startup registers etc.) and T0 is the communications overhead of the task.
This is the text book. Amdahls law, IIRC.
In reality, and also in most text books, there are exceptions where the solution scales with the number of processes.
And it should be easy enough to see: 5 machines compiling one source file each are 5 times as fast as one machine compiling 5 source files.
As long as you start gcc 5 times in a row you have
the same initialization overhead for EACH instance of gcc one after the other.
If you manage to start gcc with a couple of source files as argument to compile you save the laoding time of the binary at least. That would correspondend roughly to the alpha value.
Amdahls law is usefull for a single program/problem: try to paralelize gcc and you find the compiling source can't get speed up very much. So 5 processors running several threads of one gcc instance, those do not scale by 5.
However it says nothing about just solving the same problem multiple times in parallel.
Regards,
angel'o'sphere
Re:YES! N! Re:Not N (Score:4, Informative)
Re:YES! N! Re:Not N (Score:2)
No, NOT N (Score:3, Interesting)
Ahem. Amdahl's law still operates, and you even say so yourself. There's a constant part that cannot be removed. Let's say it takes 50 msec to initialize gcc and 500 msec to compile the average source file. Then it takes 5.05 sec to compile ten files with one copy of gcc. Ignoring commiunications, it takes 0.550 seconds to compile them on ten machines. Is 5.05/0.550 == 10? No, it's about 9.2. Therefore, the speedup is LESS THAN N. Note that the faster the actual compile time, the lower the speedup would be!
But will you notice the difference? (Score:1)
10? No, it's about 9.2. Therefore, the speedup is LESS THAN N. Note that the faster the actual compile time, the lower the speedup would be!
What about a project with
oops... take 2 (Score:3, Interesting)
Amdahl's law still operates, and you even say so yourself. There's a constant part that cannot be removed. Let's say it takes 50 msec to initialize gcc and 500 msec to compile the average source file. Then it takes 5.05 sec to compile ten files with one copy of gcc.
Then you go on to tell how using ten machines provides only a 9.2-fold speedup. But what about a project with 100 files? It would take 50.05 seconds to build everything on one machine, and it takes 5.050 seconds to build ten files on each machine. Now we have a 50.05/5.050 == 9.92 fold speedup. In practice, can you notice the difference between 9-fold and 10-fold speedup?
Does the speedup factor not approach the number of machines asymptotically?
(How can I "Use the Preview Button!" when an accidental Enter keypress in the Subject invokes the Submit button? Scoop gets it right by setting Preview as the default button.)
Re:oops... take 2 (Score:2)
Re:No, NOT N (Score:1)
Re:No, NOT N (Score:4, Informative)
Let's say it takes 50 msec to initialize gcc and 500 msec to compile the average source file. Then it takes 5.05 sec to compile ten files with one copy of gcc
Your calculation is wrong:
I explicitly said: you start gcc N times for N files.
So a call like gcc: 1.c 2.c 3.c
Because that call falls under amdahls law(in so far as a common initialization time is needed which is divided amoung the ten compile tasks).
However 10 calls:
gcc 1.c
gcc 2.c
gcc 3.c
gcc 10.c
Those ten calls scale with 10! running those ten calls one after the other on 1 machine takes exactly ten times the time then running one of them each on its own machine.
I repeat: Amadahls law is about parallelizing one algorithm. It is not about starting the same algorithm on different problem sets (differnt c files) in parallel.
Where as the first one does not scale infinite and not scale with N, the second one does(of course with some limitations in RL, e.g. if all compilers use the same file server via NFS).
The interesting difference is this: under Amdahls law you have a maximum processors up to which the solution scales. Adding more processors does not make the problem solving faster. Very often it makes the problem solving slower indeed because of communication overhead. OTOH, by just duplicating the hardware and distributing the problem "identicaly" and not "divided and parallelized" you indeed get nearly infinite scale ups. You scale up to the point where the distributing and the gathering gets to expensive. (Distributing C sources from a CVS repository to compile farm machines and gathering the *.o files or better *.so during linking back)
angel'o'sphere
Re:Not N (Score:1)
And actually, this is also not quite correct. In praxis, it is possible to achieve super-linear speedup, although unlikely. (N times as much memory is more the culprit than the additional processing power)
While speaking of distcc, one could also mention Group Enabled Cluster Compiler [sourceforge.net]. Never used one of those, I've to admit.
Re:Not N (Score:1)
e.g. it will try running two sub makes within the same depth level at the same time, but the makefile hasn't specified a dependency. for ex:
SRC_DIRS = ha_fsd \
fsd_lib \
Unless you put: ha_fsd: fsd_lib somewhere, you will run into compilation problems with sub makes and make -j. So my question is how does distcc happen to fix such dependency problems?
AFAIK, samba has written makefiles properly so you can do make -j2, so maybe it was designed for samba(distcc is part of the samba.org domain...go figure).
Re:Not N (Score:1)
Try running make -j on source packages, not all kinds of packages will compile(case in point: SGI's Linux FailSafe). The submakefiles assume a library is built and try to reference them via gcc -L../somelib/dipshit.lib. Only thing is that dipshit isn't compiled.
And try reading the gnu make manual about this.
Re:Not N (Score:1)
That's o(N) - the asymptotic speed of N.
Re:Not N (Score:2)
God gave you a shift key for a reason. Learn to master it. Or, alternatively, don't use terminology you don't understand.
Re:Not N (Score:2)
Re:Not N (Score:1)
"No room for parallelism"? Really? (Score:1)
Ever heard of compile time dependencies? Ususally a file depends on other files being compiled first.
But not every single file depends on all the previous files.
so there is no room for paralelism.
Most projects with heavy compile-time dependencies have several stages. I'll take the example of the Allegro library [sourceforge.net]: 1. preparing include files, 2. compiling the .o files, 3. creating the library, 4. compiling and linking the driver programs, 5. make install. All the substeps in each major step can usually be done in parallel because they depend only on previous major steps.
Helpful (Score:2)
Re:Helpful (Score:2)
Re:Helpful (Score:1)
Great for OpenOffice (Score:5, Funny)
With 50, 100 machines or so hooked up, OpenOffice's compile time could be reduced to as little as 1 or 2 days!!!
Re:Great for OpenOffice (Score:2)
Actually, it would be kind of cool if this was part of the default install in Gentoo - along with some P2P program for finding others online who are running the same app. Then you could download the source code and distributedly (is that a word) compile it... As long as your network is fast enough, you could significantly reduce the amount of time compiling, etc. on slow machines.
Just a thought... maybe I'm off base.
-Russ
Re:Great for OpenOffice (Score:2)
Wonderful. Then you can get rooted when others running the P2P app have modified the compiler to insert trojans into the generated binaries.
Re:Great for OpenOffice (Score:2)
Ahh... that would be a problem, wouldn't it.
Doh!
Okay, how about a super-cool, digital-signature based P2P system based on an unbreakable trust matrix? Yeah, right. OK forget it.
-Russ
Re:Great for OpenOffice (Score:2)
So now we need to.... (Score:1)
Apple Projectbuilder (Score:3, Insightful)
Does anyone here know how good the speed increase is when compiling on dual G4s versus a single proc ?
Re:Apple Projectbuilder - gcc issue, not pb (Score:2)
gcc is not a fast C compiler. It is a portable C compiler and it makes pretty good code, but it is not fast. g++ is a slow C++ compiler.
The Codewarrior compilers were fast compilers that made pretty good code.
Its all in the tradeoffs.
You can't have it all. Apple has been adding engineering hours to improve speed with gcc, but gcc will always value source language selection and target portability above all else.
Re:Apple Projectbuilder - gcc issue, not pb (Score:2)
Anyways, it doesn't all matter that much if there were to be a speed gain from dual procs or distributed compiling. So to restate the Q : do you have any idea if PB is faster on a dual1GHz than on a signle 1GHz ?
So, is it better? (Score:5, Interesting)
Re:So, is it better? - Quick answer from the site. (Score:3, Informative)
Emphasis is mine.
I guess it all depends on whether or not you want to work with production quality code or not.
Differece between distributed/parallel make? (Score:4, Interesting)
It sounds not realy reasonable to put the coding work into gcc when you like to have yacc/bison and a bunch of perl scripts and what ever else you have in your makefile also speeded up.
Regards,
angel'o'sphere
Re:Differece between distributed/parallel make? (Score:2)
It has been a long time since I tried pmake, however I frankly didn't like the thing. It was always segfaulting for some reason, while the cluster did much more complex jobs without an hassle. Unfortunately the cluster lived its life and now I don't know how things are.
It is not reasonable to consider you can go out just with some yacc/bison/perl and well-made Makefile. Here, things are much more complex. The problem is not compiling every file in a parallel machine but the whole code in small pieces. And that's hard. Some things are capable of going parallel, others not. There are several algorithms to determine what may go parallel or not. There are also some general and analythical methods that adapt data to go parallel right from start. Besides every distributed/parallel system needs to exchange information about interval steps, that every process needs to continue its work.
Frankly I don't know too deep the processes going on parallel compilation but I can guess them under my small practice in parallel computers. Imagine some photo or matrix that is divided into small pieces and sent over several machines. Every time calculations touch the edges of a small piece, the system needs data that is located on the other machines. There are a few methods to pass this information, the most popular is MPI - Message Passing Interface [anl.gov]. However it is not an universal solution. In cases when data is too heterogeneous, and calculations don't fit a common method, MPI and its cousins, are an hassle to handle with. Compilers is one of these cases as we are always dealing with different files, different compilers and tons of different interactions among data. To create systems capable of doing parallel compilation, we would need other approaches. At least, these systems should give the developer absolute transparency about the fact that compilation is being done in parallel, or else, this system will be completely useless. Imagine that the developer, while creating a new application, is forced to take into account if his code is capable of being compiled in parallel or not. This will be a huge overload to development, if the app goes over the size of Mozilla.
Big benifit (Score:5, Interesting)
~LoudMusic
Perfect for Gentoo (Score:3, Insightful)
Well unless every computer you own runs Gentoo you want to emerge world.
Could you imagine? (Score:1, Funny)
nevermind.
Unoptimized (or poorly optimized) programs (Score:1)
What's the problem? Optimizations are probably limited to each separately compiled module. Most optimizations will perform better across a larger code base. (Read the Dragon Book chapter 10 before telling me I'm wrong.) This method may produce valid code optimized by module but the code is nowhere as good as it could be. Making debuggable code is another challenge.
(If the ARE doing multiprocess optimization then I'm duly impressed. I doubt it, though.)
Re:Unoptimized (or poorly optimized) programs (Score:2)
Re:Unoptimized (or poorly optimized) programs (Score:2)
Re:Unoptimized (or poorly optimized) programs (Score:2)
Just compare GCC at max optimization and SUN cc at minimum or first level. SUN cc beats GCC even there.
So while it's true that more data -> better optimization is correct I don't think it's a very pressing issue for GCC front ends.
good software design (Score:4, Insightful)
Compiling the whole source tree should be the sort of thing you do fairly rarely (for a big project), perhaps once a night, perhaps automated so no one has to watch it.
If compile time is something that is a significant problem for you, you really need to look at your code design.
Re:good software design (Score:1)
Granted good software design should ensure that you don't have to do this often. However the typical build tools make it way too costly to fix such issues that force big recompiles. As a result they often remain unfixed.
I wish some vendor had the guts to promote a replacement for makefiles that would allow higher-level semantics to be exploited to reliably speed-up builds. Note: Apple is already doing good by promoting jam, even if jam is "just" a better make.
I had great hopes to see such a tool emerge from CodeSourcery's software carpentry contest. Too bad they didn't have the time to get to it.
Headers (Score:2)
You'd be amazed at how often it is easy to get rid of those stupid "include everywhere" headers.
Check out also ccache.samba.org (Score:5, Informative)
From the ccache homepage [samba.org], which is also a Samba hosted project
ccache is a compiler cache.
It acts as a caching pre-processor to C/C++ compilers, using the -E compiler switch and a hash to detect when a compilation can be satisfied from cache.
This often results in a 5 to 10 times speedup in common compilations.
Best of both worlds: distcc with ccache (Score:2, Interesting)
from the above link:
distcc & ccache
Has anybody yet thought of integrating distcc & ccache?
Yes, of course. They work pretty well as separate programs that call each other: you can just write CC='ccache distcc gcc'. (libtool sometimes has trouble with that, but that's a problem that we will fix shortly and it is a separate question.)
This is very nearly as efficient as making them both part of a single program. The preprocessor will only run once and the preprocessed source will be passed from ccache straight to distcc. Having them separate allows them to be tested, debugged and released separately.
Unless there's a really strong argument to do otherwise, having two smaller programs is better practice, or at least more to my taste, than making one monolithic one.
ccache (Score:1)
it basically hashes (after a cpp pass) and caches. alot of times one has to make clean, tweak a Makefile.am, change a preprocessor variable, or work with multiple different branches, such that most source files are still the exactly the same. in that case, huge speedups.
-- p
Distributed compiling (Score:1, Redundant)
LSF (Score:2)
Is this thing really usefull ? (Score:2, Interesting)
Re:Is this thing really usefull ? (Score:1)
Re:Is this thing really usefull ? (Score:1)
Re:Is this thing really usefull ? (Score:1)
Re:Is this thing really usefull ? (Score:1)
Distcc compiled programs have problem with gdb (Score:1)
It appears when a file is pre-processed on the host machine gcc does not record the directory to the pre-processed output file. When the pre-processed file is farmed out to a remote gcc build machine the remote gcc compiler (not knowing any better) compiles the file and records the remote machine's directory to the object file. Now when a user tries to debug the program gdb cannot find the source directories.
Unfortunately, this "debugging" bug has to be fixed within GCC itself. This thread [samba.org] describes how GCC might be patched to allow gdb to work correctly with distcc, but at this time no action was taken.
This is not a huge problem - distcc is still great for production builds.
Re:Distcc compiled programs have problem with gdb (Score:1)
Uh, yeah, how often do you do production builds? Every 3 month? You can let that one run over night. It's the time the test builds take that really hurts productivity, and without debugging, they're worthless. So could it be this is a non.solution to an existing problem?
Re:Distcc compiled programs have problem with gdb (Score:2, Insightful)
Even if you do have a crash gdb will still give you the stack trace of a distcc-compiled -g program complete with function names and line numbers - you just don't get the source code without setting a directory directive within a gdb session. Big deal. It's perfectly usuable.
Sometimes I'll launch production builds mid-day to correct - wait for it - mid-day production problems. This has to be done as quickly as possible, and distcc is very useful.
The gdb thing is by no means a showstopper.
security? (Score:5, Informative)
looks like this one is not necessarily a good idea to run on a university workstation cluster...
1.4 Security Considerations
distcc should only be used on networks where all machines and all users are trusted.
The distcc daemon, distccd, allows other machines on the network to run arbitrary commands on the volunteer machine. Anyone that can make a connection to the volunteer machine can run essentially any command as the user running distccd.
distcc is suitable for use on a small to medium network of friendly developers. It's certainly not suitable for use on a machine connected to the Internet or a large (e.g. university campus) network without firewalling in place.
inetd or tcpwrappers can be used to impose access control rules, but this should be done with an eye to the possibility of address spoofing.
In summary, the security level is similar to that of old-style network protocols like X11-over-TCP, NFS or RSH.
Not a new idea, but a noble one anyway (Score:3, Informative)
Once upon a time, Symantec had a C++ compiler, and with version 7.5 (1996), the build process could be spread all over a network. This did speed up compilation times as machines that were running the build service that were more or less idle would be sent files to compile, passing back the objects and binaries as oppropriate.
Oh, by the way, that compiler is now called Digital Mars C++.
That said, all the machines on the network had to be running Windows (and at that time, I think only Windows 95 or NT were the only choices available for that compiler). Further, all had to have the same version of the compiler.
For those of us that are running Linux boxes on a primarily Windows network, this system, whether GCC or something else, would be rather hard to implement without a cross-compiler. Additionally, even if all were Linux workstations (or BSD, or Solaris, etc etc etc) wouldn't binary compatibility be driven by not just the version of the compiler but the target OS as well?
It's a noble undertaking. I hope that the developers are putting thought into all the little things like this that will make it tough to pull off.
Live boot CD? (Score:5, Insightful)
Re:Live boot CD? (Score:1)
Re:Live boot CD? (Score:2)
Perhaps my biggest complaint is how long it takes to compile. Thus, this project is right up my alley. Good job, folks!
Another solution: run a gcc cross compiler (Score:1)
Here [wisc.edu], for example, is how to build a Linux cross compiler hosted on Cygwin.
gecc (Score:3, Interesting)
gess is work in progress, distcc is much more mature, but maybe you like to take a look at gecc also.
(yes, gecc is my baby)
combine it with an object file cache (Score:1)
distcc is pretty sweet :) (Score:2, Interesting)
problems with parallel make (Score:1)
[perforce.com]
Jam/MR do a better job of evenly building large, multi-directory projects.
Old News. (Score:2)
Link Time (Score:2)
-Bill
Good for boot strapping too (Score:2, Interesting)
Later, we upgraded to Motorola 88k. The new system came with a GreenHills compiler - which was so buggy it was unusable. The bugs were acknowleged, but never fixed. It was too buggy to compile gcc - I wasted many days simplifying expressions by hand to no avail.
My solution was to build a cross compiler on the 68k, and run it with a stub on the 88k for cc1 that fed the preprocessed source to the compiler on the 68k, and got back the assembler source. (There was no 88k support yet in gcc, so I had to write my own machine model. It was incompatible with Greenhills in passing and returning structs.) The preprocessor, assembler, and linker would run on the 88k - only the actual compiler pass ran on the 68k. This worked beautifully to build gcc on the 88k! And our 33Mhz 88k was so much faster, that I built a 68k cross compiler for the 88k and speeded up compiles on the 68k a great deal.
Next we upgraded to Power PC. AIX comes with no compiler at all! (IBM's compiler is very good - but expensive.) Fortunately, it comes with an assembler and linker. By dint of copying headers from AIX, and hand preprocessing and compiling to assembler, I got the preprocessor running on AIX. Then it was simple to run the cc1 stub again to compile up a native gcc for AIX. The new PowerPC was so much faster than the old 88k, that a cross compiler to speed up 88k compiles was in order also. (I contributed AIX shared lib support for gcc.)
Recently, I fired up a PowerPC cross compiler on our 600Mhz PII running Linux to speed up compiles on our old 100Mhz PowerPC AIX using the same simple technique. By using the -pipe option to gcc, the compiler on Linux runs in parallel with the preprocessor and assembler on AIX - truly efficient.
In conclusion, I want to thank Richard Stallman and the FSF for making it possible to rise above the stupid problems caused by closed source. Before the 68k, we had SCO Xenix. Basic utilities like tar and cpio were broken, reported, and never fixed - but GNU software was there with solid and reliable replacements. (Yes, I made donations and even ordered a tape.)
I wrote the same thing for MSVC++ (Score:2)
It worked pretty well, except I had a lot of problems getting fork to work right in Perl on my Win32 box without crashing, so I could get good parallelism. It even fell back to using the local machine in the event of a failure remotely at any point, so on a multiprocessor development machine and no servers to connect to, it would actually use all the processors to compile--something MSVC doesn't do normally.
The nice thing about the server script is it only has three functions: accept a file, send a requested file, and execute an arbitrary command. So it doesn't really care about what it's doing. At work, we're planning to use it to leech some cycles off the receptionist machines and managers' boxen (we all know they don't do anything all day but email anyway!).
The real limiting factor is that preprocessing is relatively slow due to seeks on the hard drive, where not all the headers fit in the disk cache at once. This is a bigger bottleneck than you'd believe.
For what it's worth, I've learned of another company that concatenated all their
I would recommend that you use C (Score:1, Funny)
By the way, have you tried Linux?
Re:Java (Score:1)
Re:Could this be a new business plan? (Score:1)
Re:What's the point? (Score:1)
like mozilla scale really well, with distcc and with gecc (http://gecc.sf.net/ ).
For smaller project (like 100k source) the gain is smaller.
Re:Distributed frontend for GNU Make (Score:2)