How to limit the number of parallel cl.exe processes during the Visual Studio solution build?

社会主义新天地 提交于 2019-12-22 05:47:26

问题


I've recently noticed that once I start building the Visual Studio solution I'm working with (~200 C++ projects), I get a very large number of cl.exe processes.

I'm not surprised by the fact of several cl.exe running in parallel, because my projects are set up with /MP option.

But I would expect that their number would be limited by the following setting in the Visual Studio "Options".

I presume that running tens of processes in parallel on the 4-core PC is not the most efficient way to build the solution.

So, basically I've got two questions:

  • Why do I observe such behavior?
  • Is it possible to limit the number of cl.exe instances?

P.S. I normally compile my solution with Visual Studio 2013 Update 4, but the same behavior can be observed with Visual Studio 2017.


回答1:


I think you need to read this where the conclusion is that you need to set up your compilation to fit VS idea of the world.

Also limit the number of parallel projects to 2-3 depending on the actual PC you run it on. If your PC is a monster with 16+ cores you might be able to go 1-2 up.

Ideally VS should have offered an option of using X threads but alas.




回答2:


To limit number of cl.exe you should use this option (at least it exists in MSVC 2015). Zero by default it means "number of CPUs" (if i'm not mistaken).




回答3:


Make sure you don't have the /MP switch on any of your projects.

Then setting the maximum parallel project builds will directly relate to the number of compilation executable instances.

Will probably be slower. An alternative is to force Visual Studio/MSBuild to a specific affinity. This will not limit threads, but will keep some spare cores for the operating system/other programs.




回答4:


Under the Tools menu, choose Options. Then under Projects and Solutions, the Build and Run page has a field "maximum number of parallel project builds".



来源:https://stackoverflow.com/questions/45379427/how-to-limit-the-number-of-parallel-cl-exe-processes-during-the-visual-studio-so

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!