Speed up Compile Times

Started by
31 comments, last by Rydinare 15 years, 11 months ago
Hello, I'm not sure if this is the right forum to post this, but I have a question regarding the compile time of my project. I'm using Visual Studio 2005 and I have the common settings turned on to speed up compile time (Incremental Building, etc). But as my project grows, its taking much longer to compile it and its becoming a burden. The project itself is about 260 Files, ranging from my own math/collision libraries, DX and OpenGL interfaces, and utilities. I was wondering, if anyone knows some neat tips or tricks to speed up compile time (anything short of using pre-compiled headers). Thanks for any suggestions.
------------Anything prior to 9am should be illegal.
Advertisement
reduce dependencies, use interfaces, forward-declare in headers instead of include, use "pImpl" technique, avoid "master" headers... separate code into libraries so you only have to compile the libs you change... if you have lots of computers sitting around there's always incredibuild, or you can go multi-core on your personal machine.

why not use pre-compiled headers?
If you're doing incremental build then you shouldn't build all of your code each time, unless you're doing rebuild all. Unless all your code are highly dependable on each other that one change would cause all to rebuild, which I highly doubted. I would use precompiled header, minimize dependency, break code into libs if possible. Other than that you can look at JAM.
If you're using a multicore machine and coding in C++, you could always upgrade to MSVC 2008 and add the /Mp switch to the compiler. It parallelizes the compilation process. The difference in speed is significant.
-------------Please rate this post if it was useful.
What's wrong with precompiled headers?
Another little tip that I've found useful is that you can compile just a single .cpp file without changing anything it affects by finding the file in the file browser (usually to the left), right-clicking on it, and selecting "Compile". It's great for simply checking syntax and that sort, where you don't plan on actually testing the changes, just making sure it compiles.
The /MP switch also works for MSVC 2005. It is an 'undocumented' feature though, so it has some rough edges and does not work in all cases.
Quote:Original post by emeyex
reduce dependencies, [...] use "pImpl" technique.


I'm in the process of adding this in, thanks for the suggestion.

Quote:Original post by emeyex
separate code into libraries so you only have to compile the libs you change...


I guess I can pull some Math code out into a Math library, but in its defense, its mostly inlined functions which are in the header itself. Would this be efficient?

Quote:Original post by emeyex
why not use pre-compiled headers?


Its a lot of work IMO, I was going to leave it for headers that I no longer need to work on. Which might be a long ways away.

Quote:Original post by Hnefi
you could always upgrade to MSVC 2008 and add the /Mp switch to the compiler. It parallelizes the compilation process. The difference in speed is significant.


I'll see about getting MSVC 2008 form my school. Does it matter which version you get (Express, or Professional, or anything in between?)

Quote:Original post by Icon
The /MP switch also works for MSVC 2005. It is an 'undocumented' feature though, so it has some rough edges and does not work in all cases.


I tried this but it said the switch is unknown. Maybe I need to update my compiler (service pack) or just switch to MSVC2008.
------------Anything prior to 9am should be illegal.
Quote:Original post by RealMarkP
Quote:Original post by emeyex
separate code into libraries so you only have to compile the libs you change...


I guess I can pull some Math code out into a Math library, but in its defense, its mostly inlined functions which are in the header itself. Would this be efficient?


What is that 'defending'? Extra code in headers means slower compile times.

Personally I think you'll find a lot can be done with simply reducing the size of your commonly-used headers, and culling dependencies.

Quote:Original post by RealMarkP
Quote:Original post by emeyex
why not use pre-compiled headers?


Its a lot of work IMO, I was going to leave it for headers that I no longer need to work on. Which might be a long ways away.

Bzzt. It's not a lot of work, and it will be much more effective than anything else you're trying.

This topic is closed to new replies.

Advertisement