tags:

views:

98

answers:

5

I have a stock mac-mini server (2.53GHz, 4GB, 5400RPM drive) which I use for iphone development. I am working on a smallish app. The compilation seems to be taking longer and longer (now about 20min). The app is about 20 small files totaling 4000 lines. It links to C++/Boost.

What suggestions do you have to speed up the compilation process? Cheaper will be better.

+1  A: 

Include all your boost headers in the precompiled header for your project.

5ound
A: 

There is something messed up. We are compiling bigger projects in fractions of the time.

Eiko
+1  A: 

I concur with Eiko. We're compiling projects that are vastly larger (including boost libraries) in much shorter time.

I'd start by checking logs. You can also view the raw compiler output in the build window (Shift+CMD+B or in the Build menu->Build Results). Xcode just makes straight gcc or llvm calls, so this may give you a better idea of what's actually happening during the build process.

jkyle
+1  A: 

As others have noted, that's way in excess of what you should be expecting, so it suggests a problem somewhere. Try toggling distributed builds -- depending on your setup it may improve things or slow them down (for a while we had a situation where one machine was servicing everyone else's builds but not its own). If you have a 1Gb network then you may get a bit of extra performance from distributed builds (especially if you have a couple of spare macminis). Also enable precompiled headers, and put both boost and cocoa headers in it.

If things are still slow then it's worth running activity monitor to ensure that you don't have some other process interfering, or even Instruments to get some more detailed information. You could find that you're trying to compile files on a network drive for instance, which will certainly slow things down. Also inside Xcode try running the option to preprocess a file and see what's in the file contents (available via right-click) to check that you're not compiling in loads of extra code.

Also with boost, try slimming it down to find only the bits you need. The bcp tool that comes in the distribution will copy only the packages you ask it to, plus all the dependencies, so you're not building stuff you won't use.

the_mandrill
precompiled headers improved life a lot.
John Smith
If you've found that's helped, then also try the preprocess trick: that'll show how many system headers are being compiled every single time. Also worth trying to minimise the use of system headers in your own header files
the_mandrill
+2  A: 

Sounds like the system is swapping, which is a common problem when compiling C++ that is STL heavy. GCC can be a complete memory pig in such a situation and two GCCs at once can easily consume all memory.

Try:

defaults write com.apple.Xcode PBXNumberOfParallelBuildSubtasks 1

And see if that helps.

If it doesn't, then the other answers may help.

bbum