Enabling Multi-Processor (Parallel) Builds in Visual Studio

Building larger solutions in Visual Studio can be tediously slow. Part of the reason is that the compiler does not make use of multiple CPU cores well. This article shows you how to change that.

Enabling Parallel Builds

Enabling parallel (aka multi-processor, aka multi-core) builds is easy: just add the compiler switch /MP (multi-processor compilation):

Dependencies

/MP is incompatible with several other options and language features. These are discussed in Microsoft’s documentation of the /MP switch. Here is what affected us with uberAgent.

#import

If you use the #import preprocessor directive with /MP you will get the following compiler error:

Error C2813: #import is not supported with /MP

The easiest way to work around that is to specify /MP1 as an additional command-line option for the source file with the #import (yes, for individual files only).

Enable Minimal Rebuild (/Gm)

This is listed as deprecated anyway, so just switch it off.

Build Time Improvements

I did not run any lengthy tests, but here is a quick comparison of a rebuild of our uberAgent project (with multiple dependent projects) with parallel builds off and on:

  • Parallel builds off (default setting): 74 s
  • Parallel builds on: 44 s

The simple changes to the configuration explained above reduced the build time by 41%.

More Information

Minimum Visual Studio Version

We are using Visual Studio 2019. That is what I tested with. Obviously, I cannot give any guarantees for older versions, but from what I read this should apply to any version of Visual Studio going as far back as 2008.

Resources

Comments

Related Posts

Visual Studio: Fixing Broken $(WindowsSdkDir) Variable

If you get weird errors in Visual Studio that basically state files like Windows.h cannot be found, the reason may be a missing or incorrect WindowsSdkDir variable. In my case, working with Visual Studio 2008 SP1 (32 bit) on Windows 7 x64 (64 bit) everything was fine until I installed the Windows 7 SDK. After that, no SDK files could be found any more and nothing would compile. Uninstalling the SDK (which I did not really need anyway - I had installed it only to get at XPerf) did not help. After some research, I found out that the Visual Studio internal variable WindowsSdkDir (which is not an environment variable) was missing from the registry. After adding the following, everything worked like a charm again:
Software development

Linux Config File Version Control & Backup on GitHub

Linux Config File Version Control & Backup on GitHub
Linux famously stores all of its settings in files, making it easy to inspect, query, or backup the configuration with a plethora of tools, including Git. However, given that Git was conceived by the Linux community, there is surprisingly little integration. As a developer, I am used to managing everything with Git. Depending on my current degree of paranoia, I may put nearly or literally everything into version control. So where’s Git for Linux config files?
Software development

Latest Posts

Beautiful Slide Decks from Markdown: Presenting with Slidev

Beautiful Slide Decks from Markdown: Presenting with Slidev
Would you like to get away from PowerPoint and author slide decks in Markdown? Then Slidev may be just what you’re looking for. It’s a web app for presentations. The fact that it’s geared towards developers shouldn’t put you off. After all, who isn’t a developer these days, with AI? Slidev comes with the beautiful Tahta themes and supports features like syntax highlighting and animations. Export options to PDF and PPTX allow for easy sharing. This article shows how to get started.
Applications