We’ve recently implemented SonarCloud into our DevOps pipeline. It runs successfully and publishes the results to SonarCloud all fine. The only issue that we have is that it’s taken our application build time from 5 minutes to around 40.
I’ve followed the guidelines given on a forum on here on how to diagnose these issues, the slowest part of the process I found from the logs was the Typescript/JavaScript analysis taking around 4 minutes. But I don’t want to exclude this analysis from the tests.
Our project is around 250k lines of code, is this length of time to run the analysis expected? Or should it be running a lot quicker?
Any help or suggestions on how to improve this would be very much appreciated.
A good first step is to parse out all the steps in your analysis that might be taking time. Maybe you’ve already done this, as you mentioned TS/JS analysis took 4 minutes, but that certainly doesn’t explain 40 minutes!
Would be great if you could share the results here. It won’t have any file names, just sensor names.
I was just thinking when I was getting this information that the analysis doesn’t actually take too long, it’s the build that has seen the increase in time:
Is there any metrics I can grab from the build that would be of any use?
The .NET analysis primarily occurs during the build phase. If you’re experiencing unusually long analysis times, it’s worth investigating further. We have a comprehensive guide on this topic:
Have you checked out this guide? It can help you identify which projects or rules are contributing most to the analysis duration. Is one standing out from the rest?
As a general rule, the analysis shouldn’t take longer than the build itself, so if it does, it’s a sign there might be a performance issue worth addressing.
Apologies for delayed reply, I had to change over the pipeline to a self-hosted agent as it was taking too long to run with the diagnostics turned on.
Is there any other way to get the diagnostic information out of the build, I let it run for two days after I included the -p:reportanalyzer=true -v:diag and it still didn’t complete.
2 days sounds really weird, as it should only produce more logs.
Instead of -v:diag, can you try to publish a binlog and either share the file (we can provide a private way to share it), or inspect it with MSBuild Structured LogViewer to find the analysis times?
The logviewer describes what parameter you need, and how to customize the output binlog file path if needed.