Source-level parallel build in Visual Studio 2005
I regularly work with Microsoft Visual Studio 2005 with SP1 on my Pentium 4 single-core non-hyperthreading based PC and occasionally run some builds on an Athlon 64 X2 dual core based PC. I noticed the compiler (cl.exe) is a single process with a single thread running, even on the dual core.
I did some digging around to see if I could enable parallel (multi processor) builds to take advantage of the extra idle core to speed up my builds and came across the following links:
Visual Studio 2005 tour and MSDN multiprocessor project builds
I was glad to find the /Mx option where x is the maximum number of project builds you want to run in parallel. I dug around the codebase and realised the build script already had /M8 specified as a parameter to the call to vcbuild.exe. I even opened up the project in Visual Studio 2005 and the setting was at 2 (since this is a dual core) as expected.
But the build still seemed to be running a single thread and not using the extra core
I then re-read the links above more carefully and saw that the option is for parallel project builds so it would only work for multiple projects and not for many source files in a single project.
I did the customary STFW/JFGI and found the new /MP option which is a part of the new Visual Studio 2008 and this option enables source level multiprocessor parallel builds.
But what about VS 2005? I did some more searching and, lo and behold, found this blog entry which says the /MP option is also available, but undocumented, in Visual Studio 2005!
Adding it to the build script’s parameter list for vcbuild.exe didn’t work, but adding it in the “additional options” window in the Visual Studio 2005 project worked and now doing a build would launch three processes of cl.exe, one which had 45 threads but took very little CPU cycles, and the other two were single threaded and utilised a CPU core each to the fullest! That was my Homer Simpson “woohoo” moment of the day ![]()
5 Comments »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
[...] permalink I just found out about the /MP option for doing source level parallel multiprocessor builds in VS 2008, and that this is also available in VS 2005 but is undocumented! This is not the same as the /Mx option for parallel project builds… blogged about it at Source-level parallel build in Visual Studio 2005 | veracity [...]
Pingback by Visual Studio 2008 will have TR1 soon - TechEnclave — February 15, 2008 @ 4:06 pm
Hi,
Thanks a LOT for this article. We wanted to buy something like Incredibuild to decrease compilation time, but now it has shrinked from 30 minutes to about 10 minutes.
Thanks ^^
Comment by Calvin1602 — July 15, 2008 @ 6:34 pm
Found it, tried it, not fully convinced… Is anybody else having problems with concurrency? For instance, in some projects, a few files import the same DLL and there are errors complaining about being unable to access X.tlh/.tli. Is this a problem inherent to /MP or are there any changes that I can make to the build projects which removes these errors?
Comment by Dan — November 30, 2008 @ 2:38 am
Well, it is an undocumented feature in VS 2005 after all, probably not fully tested. VS 2008 should not have such problems.
Comment by Vishal Rao — November 30, 2008 @ 9:01 am
[...] permalink @vrd: well you can use all 4 cores with Vista/Visual Studio 2005/2008 too For example: Source-level parallel build in Visual Studio 2005 | veracity [...]
Pingback by AMD announces 16 core CPU for 2011!! - CPU/Mobo Corner - TechEnclave — May 3, 2009 @ 10:10 am