6

I'm working on a Windows-11 computer an in my workplace, we are working with Visual Studio solutions, consisting of ±90 projects each.

The build process is configured multi-threaded with a maximum of 14 threads per build process. (As a result, 14 threads are simultaneously running in order to execute the build process.)

All those threads together, busy creating binaries, take a big part of the resources of my computer, making it almost unresponsive during the build. As that build process takes about an hour, that means that, during that hour, there is really nothing useful I can do besides turning my thumbs, watching some process in which I cannot intervene anyway.

I don't know if the blocking of my PC is due to memory, CPU or other resources being overused, but I'd like to reduce the Visual Studio usage of that particular resources up to maximum of 80% of my computer's resources, in order to avoid Visual Studio build process to block the other usage of PC.

Does anybody have an idea what can be done?

For your information: hereby some more information of my CPU:

CPU information screenshot

10
  • 1
    Can you verify using Task Manager or similar tools whether it's actually the CPU usage or the I/O or the memory usage that seems to be highest? CPU is relatively easy to prioritize, disk I/O slightly less so, while insufficient RAM would be the biggest problem and the same methods wouldn't really help with that. Commented Apr 14 at 13:12
  • 1
    Does your environment support a build-farm as a backend resource to distribute individual build tasks ? Something that can be shared across multiple developers. Commented Apr 14 at 21:48
  • 3
    you already have an answer, but if there wasn't a real one: obligatory xkcd xkcd.com/303 Commented Apr 15 at 8:20
  • 1
    @Syndic: sorry, but I prefer not to follow shortened URLs, what is that xkcd thing about? Commented Apr 15 at 8:58
  • 4
    @Dominique Its about sword fighting, of course. (btw that's not a "shortened" url, thats what URLs can be - this one's perfectly legit. Just stay away from the "random" button or several hours will suddenly vanish...... :) Commented Apr 15 at 9:06

1 Answer 1

7

First of all, @Grawity, I'd like to thank you for your comment, but I believe I've found the key issue:

I mentioned the maximum number of concurrent threads per build to be 14, but apparently that seems to be wrong: it was set to 28 ("Tools" menu, "Options", "Build and Run"):

Concurrent amount of build threads

I've modified this to 12 (first I'd modified it to 14, but due to a comment from Criggie I decided to go for 12.)

Important remark:
If you have different Visual Studio sessions opened, your modification will be spread over the others too, except if one of those others has that particular option (Build and Run) opened. As a rule of thumb, I'd advise you to close all VS sessions, just to be sure.

That 28 corresponds with the amount of logical cores, as you can see in this screenshot of the Task Manager, Performance tab, CPU page:

Task Manager screenshot

13
  • 1
    Looks like your CPU has 14 physical cores, which support hyperthreading thus 28 virtual cores. Thing is the virtual core only provides ~half the computing power of a real core. In short, you might get more responsiveness from the system by limiting compilation to 10 or 12 cores, at the cost of a slightly longer build time. Commented Apr 15 at 0:04
  • 2
    @Criggie Your comment would be right if it were 2005 - but the Intel i7-13850HX was released in 2023, so not only do you have to contend with those SMT "half-cores", but also the even more palpable differences between the P-cores and E-cores (and I'm sure caching is involved in this too...). And naturally, there doesn't seem to be a way to set MSBuild P/E core affinity - so if you set parallelism to 10 you might be unlucky and they end-up on only E-cores. Commented Apr 15 at 6:36
  • 1
    @Dai: for your information: I downloaded some tool from the Intel website and added an informational screenshot concerning my CPU(s) to my original question. Commented Apr 15 at 6:51
  • 1
    I'd concur that the most likely culprit is antivirus. Windows Defender should have an exception for Visual Studio (so only final linker output gets scanned, not the intermediate files), but other antivirus solutions, not so much. Commented Apr 15 at 8:24
  • 1
    @Dai, there are special rules for temporary files -- these are automatically quarantined and only accessible to the application that created them, but no scan is necessary yet. The same is used, for example, for the massive swap files that PhotoShop creates, scanning those would be prohibitively expensive, and false positives would lead to data loss as the user data is suddenly yanked from the running program. Commented Apr 15 at 10:44

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.