views:

2032

answers:

8

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.

+7  A: 

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.

Mark Ingram
That works for everything? The only thing i know of that it works for is the build, well at least that is what it works for according to MS.
pete blair
This will only work for C/C++ Projects. It does not have an option for C#.
David Basarab
Further, it will only make any difference if your solution has multiple projects or, possibly, build configurations.
Jon Trauntvein
+1  A: 

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.

pete blair
A: 

The /MP flag is only for builds, we at least it is according to this msdn

Now I would love to be wrong about it, but im pretty sure its just for builds. Which of course is still very useful.

pete blair
A: 

@pete @Mark Ingram - as I understand it, this is just for builds. However I'm going to try it see 'builds' includes 'tests'

IainMH
A: 

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.

Aardvark
A: 

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!

Colin Desmond
A: 

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

I do not see it under Advanced, but I can set it by typing it into "Additional Options:" under Configuration Properties > C/C++ > Command Line

+1  A: 

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"&gt;
  <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.

Olivier Dagenais