Just few minutes ago I’ve found an interesting option for Visual Studio. It can dramatically speed up compilation time. For instance, one of my project was rebuilding 19 sec, now it is 12 sec.

It’s called “/MP” - Multi Process Compilation - and you can add it to the command line for compiler in VS (I’ve tested it on VS2008 and VS2010).

As the name suggest the MP option:

The /MP option causes the compiler to create one or more copies of itself, each in a separate process. These copies simultaneously compile the source files

MP Option sometimes conflicts with other compiler switches. This will happen, when separate compiler processes write to the same output. If this might be a case, then MP switch is simply ignored.

Conflicting options: /GM (Incremental build), #import preprocessor directive, /E, /showincludes, /YC

Out of the list, the GM switch will probably cause most troubles - it is very often used in our projects.


I’ve run some tests and for project rebuilding (almost 3MB of C++ Code):
VS2008, Debug, Clean and Rebuild

  • with MP - around 12s
  • without MP - around 19s VS2010,

Debug, Clean and Rebuild (Same project)

  • with MP - 10990 ms
  • without MP - 18287 ms

tip: if you want to know how to show build times in Visual Studio just go to Tools->Options->VC++ Project Settings->Build Timing (set it to Yes). Both in VS2008 and VS2010.

If you have to speed up compilation time (especially when rebuilding whole project) remember about MP! My notebook has only 2 cores, but on core i5 or i7 (with four or more cores) the speed up probably is much higher. As long as the compilation can be separated into independent parts, the compilation time should be greatly reduced.

If you want some more details, please see this amazing post at randomascii about parallel compilation.