Feature suggestion: Parallel analysis in MAVEN/SonarScanner

Following up on Parallel analysis in MAVEN/SonarScanner feature suggestion would be parallel analysis in MAVEN plugin.

Last time I checked, parallel execution in Maven was broken. Also, typically you only run the scanner once (for the root module), so you would only see any gains if you are running other tasks at the same time.
See comments here: https://jira.sonarsource.com/browse/MSONAR-7 (including a ticket in maven)

1 Like

Since the referenced ticket has been created roughly 10 years ago, there is a chance that MAVEN has fixed/changed how it internally does parallelization.

However, it’s not necessarily MAVEN that can do parallelization, I believe it could also be done completely in a plugin like Sonar Scanner.

After all, I could start 26 maven builds on a machine with 80 cores with different values for:

<sonar.inclusions>**/A*.java</sonar.inclusions>
<sonar.inclusions>**/B*.java</sonar.inclusions>

…

in pom.xml and if I were able to consolidate the results into one SonarQube report, then that would probably speed up analysis by a considerable factor.

As a side note, for junit tests we taking a similar approach although the “distribution by first letter” there is used to distribute tests over different hardware (we’re using junit/jupiter parallelization also for speeding things up in a single process).

I understand that some checks might not work reliably with that kind of parallelization, e.g. duplication checks, checks for usages of @depcecated or unused variables etc.

But all checks that do not look beyond a single file should work nicely, and for short-lived branches that are reviewed through pull requests, that would be ok for me.

The ticket has relevant comments dating less than 3 years ago.

Anyway, if we were to do that internally (within the task), it would make sense to multithread the execution of sensors. That way the checks and other computation done by the sensor can be split effectively and the scanner can still aggregate all the results. It wouldn’t be specifically done for maven. That idea comes back from time to time and is one possible solution (with a lot of drawbacks!) to speed up SonarJava in certain running environments.
As you pointed out, there is already a ticket with the goal of speeding up SonarJava 6.x and the team will work on finding a solution. Your suggestion has been linked to it.
Thanks for taking the time to write here!

1 Like

That’s right, the bug regarding parallel builds seems to have been fixed on maven side:

https://issues.apache.org/jira/browse/MNG-5965