4
votes

Oftentimes when building a large solution with many projects in Visual Studio 2010, Windows 7 Resource Monitor will show that devenv.exe as Not Responding, however Average CPU reads a low number like 0.91 like shown:

Visual Studio 2010 slow build on AMD Phenom II x4

and this is on Windows 7 x64 with a AMD Phenom II 920 4-core CPU, 8 GB RAM. Visual Studio is not responding, yet it hardly seems to be using any CPU resources.

When I tried running the build with msbuild.exe and the switch "/maxcpucount:4", the Average CPU value still stays low, and the RHS graphs never show a value above 5-10%.

Why doesn't Visual Studio 2010 (or msbuild) seem to be taking advantage of the CPU(s) during a build?

3
There is so much more to a computer's performance than a CPU. For instance; how much time is spent reading your solution from disk? - vcsjones
If your system is running low on memory, you're going to start thrashing your page file like mad and compiles will slow to a crawl. A large translation unit with lots of #includes can easily consume hundreds of megabytes. Multiply that by the number of parallel processes, and you can easily consume gigabytes. - Adam Rosenfield
@vcsjones I checked my disk usage in Resource Monitor when opening a project, and noticed that it approaches 1 MB/s. @Adam I have seen Windows 7 sometimes show a 'low on memory' message when I've opened several large solutions and I haven't rebooted in a while, but in this case I was using 3-4 out of 8 GB RAM. - T. Webster
I was thinking the same and the answers here dont seem to explain that much. Im using 17% of CPU. 30% RAM. 1% disk. Why doesn't it take advantage of my machine. Builds seem to take the same time on a supercomputer or a potato. Doesnt makes sense. It would have been better for me to buy 5 rubbish computers and build across them with Incredibuild. - Gary Carlyle Cook

3 Answers

5
votes

Building a project potentially involves a lot of disk I/O. This can take a fair bit of time, but will not produce much in the way of CPU load.

As for why it shows as not responding, my guess would be that the build process is for some reason (as in, someone did a poor job of implementing it) blocking the application from responding to requests from the OS. An application doesn't need to reach 100% CPU utilization to be considered "Not Responding", it just needs to get its main thread stuck somewhere that prevents it from responding to the OS in a timely fashion.

2
votes

It seems that MSBuild does not like to build multiple projects in parallel, only multiple files in one project in parallel.

0
votes

Why is it slow and doesn't work as expected? Well, because its built from scratch using cutting edge technologies. That's why!

(Rant: VS 2010 is huge step back IMHO. VS 2008 is much more stable/responsive (and works) but lets leave the personal opinions aside)

Two workarounds to take adavantage of multiple cores:

  • Set MSBuild as an external tool as outlined here and assign it a shortcut (like Ctrl+Shft+B) for quick access.
  • Set BuildInParallel attrib of MSBuild task to true

    <Target Name="RunInParallel">
      <MSBuild BuildInParallel="true"
               Projects="@(Projects)"
               Targets="RunCodeAnalysis">
      </MSBuild>
    </Target>