Slow build times

My build somewhere after 1 may started taken a lot more time with sonar going from 3 minutes to 1 to 5-6 hours if it completes. I have narrowed it down to this rule

     Total analyzer execution time: 21996.412 seconds.
     NOTE: Elapsed time may be less than analyzer execution time because analyzers can run concurrently.
     Time (s)    %   Analyzer
     21971.954   99   SonarAnalyzer.CSharp, Version=, Culture=neutral, PublicKeyToken=c5b62af9de6d7244
     21735.002   98      SonarAnalyzer.Rules.CSharp.UnusedPrivateMember

This seems to coincide with the release of the engine beginning of May - but it could also have to do with the structure of the code.

Task         : Prepare Analysis Configuration
Description  : Prepare SonarCloud analysis configuration
Version      : 1.6.0
Author       : sonarsource
Help         : [More Information](
[command]C:\ag2\_w\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.6.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:* /o:*
SonarScanner for MSBuild 4.6
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
19:50:24.339  19:50:24.327  Loading analysis properties from C:\ag2\_w\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.6.0\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml
19:50:25.23  Processing plugin: csharp version
19:50:25.418  Processing plugin: vbnet version
19:50:25.418  Processing plugin: securitycsharpfrontend version

Environment build tasks for azure devops, yaml pipeline, dotnet core 2.2 code base.

Anyone else seen this dramatic change?

Hi Michel,

AFAIK, the changes done beginning of May about the C# analyzer should not impact the analysis duration (mainly security hotspot rules were removed so the analysis should in fact be faster).

When you say that “it could also have to do with the structure of the code”, what are you thinking of?

Also, if you can copy-paste some logs with timestamp information (maybe in debug mode to have more details), this could help understand the behaviour.

BTW @michelandre, could this be related to MSBuild scans takes much longer since March 25?

I dont think its related to the march 25 issue at least not the security rules, the change coincided with the may release but it might be unrelated. Times got to normal when disabling S1144/UnusedPrivateMember and majority of time seem to be related to one project but havent been able to isolate what pattern caused it to trigger. Unfortunately timings have gone is not retained, I could retry with some logging what parameters is needed?

hi @michelandre. I’m glad you found the problem and that disabling S1144 solves the slow build time.

The rule has been updated in SonarCSharp 7.12 to verify more unused types. (not only class and struct as before, but also enum, interface and delegate). I expect this is a possible reason for taking such a long time.

It has also been modified in 7.10, but that should have improved the perf…

Update: we’ve fixed the performance problem we were having with the UnusedPrivateMember rule (#2474 ). The fix is included in the 8.13 release. It should get deployed to :sonarcloud: in the following week.