High CPU Usage .NET Framework

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)

    Sonarqube version: * Enterprise Edition - Version 9.9.2 (build 77730)
    Sonarscanner: sonar-scanner-4.8.1.3023

  • how is SonarQube deployed: ZIP

Hello!

Issue is that we are noticing heavy CPU usage, while running SonarScanner for MSBuild.It runs the VBCSCompiler process which uses all CPU.So when we run 2 parallel jobs, the server CPUs gets up to 100%.

We’ve tried increasing CPUs, but nothing changed.

Server parameters now`

RAM:12.0 GB
CPU: 4 sockets, 16 processors
Windows Edition: Windows Server 2019 Datacenter
.NET Framework v4.8

Hi,

Welcome to the community!

And without analysis, CPU usage doesn’t reach 100%?

 
Ann

Hey Ann. thank you for your response!

No It doesn’t. Only when that process is running.

Hi,

Let me re-ask: does a build without analysis peg the CPU?

And does the CPU reach 100% during the build or during the end step of analysis?

 
Thx,
Ann

No without analysis it lasts only few seconds.

Hi,

Does the CPU reach 100% during the build?
Does the CPU reach 100% after the build, during the end step?

 
Thx,
Ann

Yes in both stages, it gets up.

Hi,

Thanks. Can you share the specs of your machine and give us an idea of the size of the project? It’s not unusual for analysis to be intensive, especially on a large project. And if the underlying host is underpowered, what you’re seeing might be expected.

 
Thx,
Ann

We have many applications, small and large ones…NET core applications for example have no trouble.We are noticing this issue only with .NET Framework apps.

Lines of code examples`

  • 18569, 60-70%, .NET Framework v4.8
  • 10144, 60-70%, .NET Framework v4.8
  • 27,346, 90-100%, .NET Framework v4.8
  • 57,605, 90-100%, .NET Framework v4.8
  • 153,408, 100%, .NET Framework v4.8

Server parameters now`

RAM:12.0 GB
CPU: 4 sockets, 16 processors
Windows Edition: Windows Server 2019 Datacenter

Hi,

I find these pretty reasonable:

But this is a little more interesting, IMO:

You say it only happens with .NET Framework apps. What other kind of projects do you have under analysis?

 
Ann

So you think it’s okay to have 90-100% load while analyzing 50K lines?If so, what could you suggest?

We have .NET 5, 6, 7 applications with 40-50K lines which only use 10-20%.

Hi,

Analyzing large projects can be intensive.

And this is helpful to know.

I’m not sure there’s anything to be done here, but I’m going to flag this for the experts.

 
Ann

1 Like

Hey there,

This seems more like an MSBuild issue, especially since you are not encountering the same level of CPU usage on the newer .NET versions.

A suggestion would be to set nodeReuse to false in the MSBuild arguments during the build, to prevent any nodes from hanging during and after the build.

If that does not make the situation any better, you can consider raising this to the runtime or the MSBuild team.

Regards,
Greg