Why can't Visual Studio run on more than one c

2019-06-19 00:09发布

I'm running Visual Studio 2008 with the stuff-of-nightmares awful MS test framework. Trouble is that it's sending my CPU to 100% (well 25% on a quad-core).

My question is why can't Visual Studio run on more than one core? Surely M$ must have a sufficient handle on threading to get this to work.

8条回答
在下西门庆
2楼-- · 2019-06-19 00:45

For Visual Studio 2010 Go to Tools > Options > Projects & Solutions > Build and Run.

You will then see an entry to enter a number for the 'maximum number of parallel project builds'; my PC has an i7-3770 CPU, a Quad Core with HyperThreading, so it is set to 8.

For information on different versions of Visual Studio go here and select your version: https://msdn.microsoft.com/en-us/library/cyhcc7zc(v=vs.100).aspx

e.g. for Visual Studio 2010 this property only affects C++ builds:

Specifies the maximum number of Visual C++ projects that can build at the same time. To optimize the build process, the maximum number of parallel project builds is automatically set to the number of CPUs of your computer. The maximum is 32.

But for Visual Studio it's for C++ and C#:

maximum number of parallel project builds Specifies the maximum number of Visual C++ and Visual C# projects that can build at the same time. To optimize the build process, the maximum number of parallel project builds is automatically set to the number of CPUs of your computer. The maximum is 32.

查看更多
做自己的国王
3楼-- · 2019-06-19 00:50

You can ask VS to compile multiple projects in parallel as well as compiling parallelly (!?) within a project.

Tools > Options > Projects and Solutions > maximum number of parallel projects build.

This will build C++ and C# in parallel as well!

查看更多
男人必须洒脱
4楼-- · 2019-06-19 00:53

I'm sure it's very hard. Huge existing GUI-heavy non-threaded code base to multi-threaded. Sounds like a 10 to me.

But it seems to use multi-cores to me. The Intellesense seems threaded. The build system has multi-project building and for C++ multi-file building as well.

You problems with these tools sounds a bit deeper then how well they use you CPUs.

查看更多
smile是对你的礼貌
5楼-- · 2019-06-19 00:55

We also added multiple core support for doing multi-threaded builds on the command line for those of you with a lot of projects and long build times. Enabling multiple core support requires only a few new properties, and MSBuild manages all of the work to schedule projects efficiently and effectively. The MSBuild team has tested this ability to scale by building some projects on a 64-CPU machine.

that is from somasegar blog

So they sort of started doing it, well at least for the build.

查看更多
手持菜刀,她持情操
6楼-- · 2019-06-19 00:56

Now that Visual Studio 2010 has been released for a bit, consider upgrading to make use of the parallelTestCount attribute in MSTest's .testsettings file, as described at How to: Run Unit Tests Faster Using a Computer with Multiple CPUs or Cores.

There are a few limitations, such as:

  1. Only simple unit tests are supported (i.e. excludes coded UI tests and ASP.NET-hosted tests)
  2. Tests must be thread-safe (all tests are run in the same process)
  3. You can't collect code coverage (among other data & diagnostics) at the same time

Example, using 0 to mean auto-detect (the default is 1):

<?xml version="1.0" encoding="UTF-8"?>
<TestSettings
  name="Release"
  id="{GUID}"
  xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
  <Description>
    These are default test settings for a local test run.
  </Description>
  <Execution parallelTestCount="0">
    (...)
  </Execution>
</TestSettings>

A few blogs have noted that you might have to close and re-open your project for Visual Studio to notice you added/changed that attribute. Also, if you edit the test settings file using the GUI, you'll probably have to re-add the parallelTestCount attribute.

查看更多
兄弟一词,经得起流年.
7楼-- · 2019-06-19 00:58

I have VS2008 running on all 4 CPUs. Just set this environment variable / project flag.

/MP

(It can be set in C/C++ Settings, Advanced. In project settings)

Edit: The MP flag can also accept a number, e.g. /MP2 which means it will only run on 2 cores. Leaving it as just /MP means it will run on the maximum amount of cores.

Edit2: The MP flag is probably for the compiler only.

查看更多
登录 后发表回答