Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does .Net Core compiling time decrease proportionally with the number of CPU cores?

I'm building a new PC. My main usage will be coding C# .Net Core projects. I wonder whether the added cores from CPU such as Intel 12th gen i7-12700f (10 cores/20 threads) would be worth the money.

Ideally, the compiling time should improve almost linearly with the number of cores as in case with the Chromium compiling benchmarks (specifically, with the Intel 12th gen CPUs):

https://www.youtube.com/watch?v=xBDFCoGhZ4g&t=1021s

https://www.youtube.com/watch?v=2WklVah7ERo&t=561s

Edit 1:

I did search before making this quesstion. I'm aware of the other posts such as:

https://learn.microsoft.com/en-us/visualstudio/msbuild/using-multiple-processors-to-build-projects?view=vs-2022

Does Visual Studio 2012 utilize all available CPU cores?

I know .Net compiler can take advantages of multi-core.

My question is specifically about how C#/.Net compiling time would scale with the number of CPU cores (within one CPU generation such as Intel 12th gen) as in case of C/C++/Chromium compiling benchmarks. I hope this is still a legit question.

Edit 2:

This question about the compiling time of one single medium-size project. Not compiling multiple projects which certainly scales with cores.

like image 918
Hieu Avatar asked Sep 11 '25 23:09

Hieu


1 Answers

this is probably off-topic, but other questions like this exist for earlier versions of .net, similar to this: Does Visual Studio 2012 utilize all available CPU cores?

First you want to make sure that multi-processor compilation is enabled: Enabling Parallel Builds Enabling Parallel Builds

Then you want to make sure you are running Visual Studio 2022 so you can take advantage of all 64 bits in the pipeline.

Then to determine if it is worth the extra $$$, use this chart from xkcd: Is It Worth the Time?

This is actually a serious post. What improvement measure would make it worth it? If you care compiling 50 times a day, and the improvement was only 1 second, then it is worth spending 1 billable day worth extra. This chart states that over 5 years, those seconds will add up to 1 entire day of additional billable work.

Lets just low ball that at $200.

Now if you are like me, you will be compiling more than 50 times in a day, and each compilation cycle can be up to 60 seconds. The saving of having additional cores even so the rest of the OS and Spotify and your web browsers can keep churning away while you wait for builds, means that we will easily get at least 1 second, on top of the VS compilation.

So now we have a saving of $800. Even before we benchmark it, we can easily justify spending $800 extra, as long as you are happy with the 5 year investment.

Have I benchmarked these latest CPUs against VS 2022, no. But if I did that I'd very quickly talk myself into buying a new dev rig ;) If you are performing frequent compilations then all improvements to CPU, RAM, HDD and general bus speed will help, but it is most common to find that the HDD is the bottleneck for performance. After all that compilation the files need to be written somewhere, so if you are looking at the top of the range but are on a budget, I would invest in the best HDD and a good CPU, rather than the other way around.

like image 102
Chris Schaller Avatar answered Sep 14 '25 12:09

Chris Schaller