Slow Dotnet Core builds and tests for small repositories

  • versions used : 8.9 Developer Edition
  • Azure DevOps, Self-Hosted agents

Hi team,

We have several dotnet core builds which take long time in both build and test. This doesn’t happen for all, and the agents are the same along with their tasks (using same task group).

For example, we have a repository with with around 14k lines and with SonarQube. ​
image

Without SonarQube it takes:
build 59s
test 1m 47s

With SonarQube:
build 6m 21s
test 2m 52s

Now, I understand from other posts here that some rules can cause this, so we can add a flag which outputs the analyzers execution time.

Below several outputs of this from build.

     Time (s)    %   Analyzer
       36.343   71   SonarAnalyzer.CSharp, Version=8.22.0.0,  Culture=neutral
        10.213   20      SonarAnalyzer.Rules.CSharp.CbdeHandlerRule
         4.065    7      SonarAnalyzer.Rules.SymbolicExecution.SymbolicExecutionRunner

     Time (s)    %   Analyzer
        36.271   75   SonarAnalyzer.CSharp, Version=8.22.0.0, Culture=neutral,         
         9.680   20      SonarAnalyzer.Rules.CSharp.CbdeHandlerRule
        3.839    7      SonarAnalyzer.Rules.SymbolicExecution.SymbolicExecutionRunner

What can I do to solve the issue? If the solution is to disable rules, how can I find the rules in Sonar and disable them? They don’t have the above names.

1 Like

Hi @LeathelBacon,

From what I can see in your examples, most of the time is spent while processing S3949 - Calculations should not overflow.

You can disable this rule by creating an .editorconfig file (if one does not already exists) and adding the following configuration:

[*.cs]
dotnet_diagnostic.S3949.severity = none

Some of the rules are slow depending on the context and disabling them could be a solution, other might take some time due to the analysis complexity (there are multiple rules run by the SymbolicExecutionRunner). Disabling them will reduce the time but will also reduce the value you get by running the analysis.

We are working to improve the performance and we appreciate feedback.

If the solution is to disable rules, how can I find the rules in Sonar and disable them? They don’t have the above names.

The only way to do this now is to search by the class name (the string displayed in the report) in our codebase and find the diagnostic ids. In the next version of Roslyn this will improve as the id will be part of the report: Print DiagnosticIds in the Report Analyzer Format · Issue #51695 · dotnet/roslyn · GitHub