We have recently upgraded from SonarQube 8.4.2 to SonarQube 8.9.1. On 8.4, scans during ci builds take ~3 mins. With 8.9, they take ~11 mins. We run a couple thousand builds per week so this is a significant increase.
I have found the main issues to be slow analysis of files. At times, there have been even more significant increases in scan times where some files are taking 8-10 or more seconds per file which causes builds to take hours. The below numbers occur on separate sonar infrastructure with no other builds running against it. The below build was run using sonar-maven-plugin:184.108.40.2065 and SonarQube 9.1.
17:15:42 [INFO] 97/97 source files have been analyzed 17:15:42 [INFO] Slowest analyzed files: 17:15:42 falcon-planner-service/src/test/java/com/cvent/falcon/planner/services/eventAppContent/HeaderThemeSettingsHandlerTest.java (3614ms, 19102B) 17:15:42 falcon-planner-service/src/test/java/com/cvent/falcon/planner/services/HomeScreenSchedulerHelperTest.java (3489ms, 35948B) 17:15:42 falcon-planner-service/src/test/java/com/cvent/falcon/planner/services/eventAppContent/EventGuideSettingsHandlerTest.java (3466ms, 100169B) 17:15:42 falcon-planner-service/src/test/java/com/cvent/falcon/planner/services/eventAppContent/CustomPageSettingsHandlerTest.java (3332ms, 16378B) 17:15:42 falcon-planner-service/src/test/java/com/cvent/falcon/planner/dao/EventAppBuilderSettingsAuditTest.java (3074ms, 3930B) 17:15:42 falcon-planner-service/src/test/java/com/cvent/falcon/planner/services/ExperimentServiceTest.java (2878ms, 2430B) 17:15:42 falcon-planner-service/src/test/java/com/cvent/falcon/planner/services/EventGuideCardsHelperTest.java (2504ms, 13938B) 17:15:42 falcon-planner-service/src/test/java/com/cvent/falcon/planner/services/EventServiceTest.java (2483ms, 10919B) 17:15:42 falcon-planner-service/src/test/java/com/cvent/falcon/planner/services/EventMobileSettingsServiceUpdateTest.java (2478ms, 10150B) 17:15:42 falcon-planner-service/src/test/java/com/cvent/falcon/planner/services/eventAppContent/ContentVisibilityHandlerTest.java (2303ms, 34011B) 17:15:42 [WARNING] Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them.
I also see the below line in the logs but I’m not sure if this is a separate step or it includes the scan time of the slow files.
17:17:03 [INFO] Sensor JavaSensor [java] (done) | time=80455ms
This only happens for Java projects in Jenkins. Running the same command locally finishes in 1-2 mins. We also have JS projects with no issue.
We have tried:
- increasing the build machine cpu/memory
- increasing the sonar host cpu/memory
- increasing/decreasing the background worker threads
- increasing iops of the build machines
- not using docker volumes with the sonar host
- using the default Sonar Way rules
Also we’ve tried increasing the java memory options in the docker container to the following.
- sonarComputeJavaOpts: ‘-Xmx16G -Xms8G’
- sonarWebJavaOpts: ‘-Xmx4G -Xms2G’
- sonarSearchJavaOpts: ‘-Xmx4G -Xms4G’
Any suggestions on decreasing these scan times?