C++ How to limit visual studios multi-processor compilation

Viewed 25970

Every time I compile using visual studio the rest of my computer crawls because visual studio is hogging all the processors. Is there a way to limit the number of processors that visual studio is using so I can still get some work done during the compilation time?

By the way, I am using visual studio 2013 and 2015 and programming in C++.

Thanks!

7 Answers

Setting the "Maximum number of parallel project builds" is not the answer if you have a single C++ project with lots of .cpp files and you don't want 8 building at once. To control that, go to Tools > Options > Projects and Solutions > VC++ Project Settings, and in the Build section, set Maximum Concurrent C++ Compilations to the max number of .cpp files you want to compile in parallel. The default setting appears to be 0, which apparently means there is no maximum. I have 4 cores/8 threads, and set this value to 4, and VS now only compiles 4 files at a time instead of 8.

These instructions are based on Visual Studio 2017, but I think it's been this way for a few releases.

Setting Max Concurrent C++ Compilations

A more optimal answer comes from Mikhail Virovets at https://developercommunity.visualstudio.com/comments/497084/view.html

Decrease the compiler process priority to below normal. This means it will use as much CPU as possible but without interfering with other things you're trying to use.

Define a registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\cl.exe\PerfOptions

Then create a DWORD value named CpuPriorityClass = 5 (5 means "below normal").

Note that this affects all processes named "cl.exe".

Related