I do not want to state an incomplete XY problem, so here's the full situation:
I am running builds in Visual Studio on my Windows 7 machine, using both parallel builds and parallel compilation. Disabling either of these is not an option.
My problem is that occasionally, this spawns so many
cl.exe (compiler) processes that the whole machine slows down, UI gets unresponsive etc.
The machine has 12 effective cores (6 w/hyperthreading).
My idea to solve this problem is to restrict
cl to only 11 or 10 of the cores available, so that it cannot turn the whole machine unresponsive. Unfortunately, I was not able to find a way to do so.
I've found ways to set application affinity by using a shortcut (
.lnk) to the application, but that is not applicable in my situation because
cl.exe is launched by Visual Studio internally, and not directly by me.
I've also found ways of setting the affinity of a process already running, but that's not useful for me either (if nothing else, the
cl.exe processes end and get spawned throughout the build, they're not long-running ones).
I am looking for a way to do the Y part, but alternative ways to solve the X problem (unresponsiveness caused by too many processes running, stopping, and starting) are welcome solutions as well.