checkstyle / sonar-checkstyle

Support on Checkstyle in SonarQube. Officially transfered from https://github.com/SonarQubeCommunity/sonar-checkstyle
GNU Lesser General Public License v3.0
171 stars 70 forks source link

Slow checkstyle analyse on 10.14.2 #510

Closed ArnaudAndr closed 2 months ago

ArnaudAndr commented 5 months ago

Sonar version: [[YOUR VERSION]] Checkstyle sonar plugin version: 10.14.2

Steps to reproduce or description of problem:

Hello ! We recently upgraded checkstyle from 10.12.5 to 10.14.2 and experienced a strange behaviour : Checkstyle time is very slow One example on one of our maven modules :

On 10.14.2 : [INFO] Sensor CheckstyleSensor [checkstyle] [INFO] Checkstyle output report: /builds/pao/pao/target/sonar/checkstyle-result.xml [INFO] Checkstyle configuration: /builds/pao/pao/target/sonar/checkstyle.xml [INFO] Checkstyle charset: UTF-8 [INFO] Sensor CheckstyleSensor [checkstyle] (done) | time=73055ms

On 10.12.5 :

[INFO] Sensor CheckstyleSensor [checkstyle] [INFO] Checkstyle output report: /builds/pao/pao/pao-framework/pao-framework-converter/target/sonar/checkstyle-result.xml [INFO] Checkstyle configuration: /builds/pao/pao/pao-framework/pao-framework-converter/target/sonar/checkstyle.xml [INFO] Checkstyle charset: UTF-8 [INFO] Sensor CheckstyleSensor [checkstyle] (done) | time=619ms

It seems to check the entire application on each module (as the output and configuration directories seems to be global on last version)

I saw this change that may explain :

                          -  .onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE).build(),
                         +  .onQualifiers(Qualifiers.PROJECT, Qualifiers.PROJECT).build(),

https://github.com/checkstyle/sonar-checkstyle/commit/d77b04fe37c50127ad13d664cd8595642df80390#diff-b18d612a4942bebba0e682d44470452ac6e57138209663aba4c578a8c0646136

Does this behaviour seem correct on your side ? In this case, could our configuration explain the problem ?

rnveach commented 5 months ago

@ArnaudAndr I can't answer on the sonar plugin, but you may want to check if this a slow down with the library itself by using the CLI. https://checkstyle.org/cmdline.html

We had an issue recently where a change in the grammar caused a slow down, but it should be fixed. Is your project open sources?

https://checkstyle.org/releasenotes.html#Release_10.14.1

Performance regression from 10.12.4 to 10.13.0.

muhlba91 commented 5 months ago

did you check what @rnveach proposed?

as for the change in the qualifiers scope: since SQ 7.7 the MODULE scope is deprecated (and doesn't exist anymore). the replacement is reverting to the PROJECT scope. since the MODULE scope didn't exist anymore since 7.7, i'd assume/hope this change doesn't have any implications for how SQ processes a scan. this is for as long as they don't keep some backward compatibility in place with specific logic; however, even then we must migrate away from the MODULE scope due to it's deprecated/unsupported nature.

Bananeweizen commented 5 months ago

I can confirm that this is a bug within this project. The module to project change because of the deprecation might cause it. We run Sonarqube on large maven aggregator projects.

With the old 10.12.5 every single maven module report file was evaluated on its own, taking just some seconds: grafik

Now instead the (combined) maven aggregator report file is evaluated for each module: grafik

That leads to a massive slowdown if you have several hundred maven modules in the aggregator. I'm still trying to find a local workaround, but every test takes 10 hours for our project. :) Due to that huge time I also can't say yet, if the results are generally okay (I would assume that Sonarqube skips all the duplicate findings).

Bananeweizen commented 5 months ago

Looking at it more closely, it might be related to the upgrade from sonar-api 7 to 9. The output report being logged in the previous images is from https://github.com/checkstyle/sonar-checkstyle/blob/23d669d31cb08a0eb12422897373d1ff92dd165c/src/main/java/org/sonar/plugins/checkstyle/CheckstyleExecutor.java#L97. that xml report is located with filesystem.workdir, see https://github.com/checkstyle/sonar-checkstyle/blob/23d669d31cb08a0eb12422897373d1ff92dd165c/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java#L130. The filesystem is injected from Sonarqube core, and might have changed its behavior for multi module maven projects between 7 and 9.

AravindNSS commented 5 months ago

Hello, We are using SQ Community Edition v9.9.4 and Sonar-Checkstyle 10.14.2 Our Developers have also reported this issue. With v10.12.5, the Jenkins build(that does only sonar-scan) used to take 2.5hrs and now with v10.14.2 it is taking around 2.5 days to complete the analysis.

Is there any temporary workaround for this issue?

Thanks

muhlba91 commented 4 months ago

this is an interesting one...

just for completeness: i strongly despise reverting the change and including the deprecated scope again. according to the SQ API documentation, modules don't exist anymore at all since 7.7. having this scope included again makes it pretty undefined on how it's handled or if it's still being used on the SQ side (and even if it were, no one knows for how long). it'd be a pretty bad hack-around hoping that SQ never changes any piece of code on their side related to the maybe still functioning pieces. besides, it might not even solve this issue if SQ changed their file system implementation.

currently, i see one feasible path forward: opening a Sonar issue (https://sonarsource.atlassian.net/projects/PLUGINAPI/issues/?filter=allissues) or posting in the community forums (https://community.sonarsource.com). @Bananeweizen : since you have the data points regarding scan times and your multi-module project data, would you be OK with taking care of this and cross-referencing the issues/posts? (however, please wait for 10.15.0 to be available first - see https://github.com/SonarSource/sonar-update-center-properties/pull/534).

muhlba91 commented 4 months ago

@Bananeweizen any updates from your side with 10.15.0 and/or related to an official Sonar issue?

jloisel commented 3 months ago

We have upgraded to Checkstyle 10.16.0 and it's very slow too for a while now. Takes about 40min (was 12min before) sonar analysis alone, due to checkstyle taking 5+sec per maven module. It used to be less than 1sec per module. We have 500+ maven modules in our project.

We have Sonarqube 9.9.5 Community Edition.

romani commented 3 months ago

@jloisel , can you downgrade to earlier versions to catch in what version we got regression?

jloisel commented 3 months ago

I can. How can I install a specific version of checkstyle / sonar plugin? by dropping the jar manually inside the folder?

EDIT: downgraded by downloading plugin manually into sonar's extensions/plugins folder. Trying 10.12.3 now.

jloisel commented 3 months ago

I confirm, on checkstyle 10.12.3, sonar analysis takes around 11min. On 10.16.0, it takes around an hour:

image

Same quality profiles, same sonarqube server version.

romani commented 3 months ago

In 10.13.0 https://checkstyle.org/releasenotes.html#Release_10.13.0 we released string templates that was a performance problem.

That was considered to be fixed at https://checkstyle.org/releasenotes.html#Release_10.14.1 by https://github.com/checkstyle/checkstyle/issues/14566

But looks like still a problem.

@nrmancuso , looks like we need to speed up removal of string templates to bring speed back to good.

@jloisel , are your sources open ? We just try to find a way to reproduce problem.

romani commented 3 months ago

@jloisel , do you have ability to run checkstyle as maven plugin or CLI ? Over this test project. We need to know if problem is checkstyle Library due to parsing or it is Sonar specific problems.

jloisel commented 3 months ago

We run checkstyle using:

mvn sonar:sonar

Our source is not open.

With sonar checkstyle plugin 10.16.0:

[INFO] 13:29:16.852 Checkstyle output report: /home/ubuntu/.jenkins/workspace/backend-sonarqube/target/sonar/checkstyle-result.xml
[INFO] 13:29:16.853 Checkstyle configuration: /home/ubuntu/.jenkins/workspace/backend-sonarqube/target/sonar/checkstyle.xml
[INFO] 13:29:16.854 Checkstyle charset: UTF-8
[INFO] 13:29:22.269 Sensor CheckstyleSensor [checkstyle] (done) | time=5417ms

With plugin 10.12.3:

[INFO] 14:02:31.647 Checkstyle output report: /home/ubuntu/.jenkins/workspace/backend-sonarqube/billing/billing-zoho-retrofit/target/sonar/checkstyle-result.xml
[INFO] 14:02:31.655 Checkstyle configuration: /home/ubuntu/.jenkins/workspace/backend-sonarqube/billing/billing-zoho-retrofit/target/sonar/checkstyle.xml
[INFO] 14:02:31.666 Checkstyle charset: UTF-8
[INFO] 14:02:32.196 Sensor CheckstyleSensor [checkstyle] (done) | time=555ms

From what I understand, it seems like:

I think the problem relies there. It's not really that the plugin is slower, it's because it's parsing the the global xml file for each module.

nrmancuso commented 3 months ago

@nrmancuso , looks like we need to speed up removal of string templates to bring speed back to good.

I am not convinced that this is the issue here; regardless, we will be removing support for string templates soon.

romani commented 3 months ago

@jloisel , can we ask you to run our cli over root folder of project https://checkstyle.org/cmdline.html#Command_line_usage With your config. To measure a time of execution, exact violations does not matter much. To make it clear, if this is core parsing or some sonar plugin issue. Let me know if you need help on how to run by CLI.

jloisel commented 3 months ago

EDIT: ran the cli on a single maven module:

time java -jar checkstyle-10.16.0-all.jar -c sun_checks.xml design/design-entity/src/main/java/* --debug

...

Audit done.
Checkstyle ends with 1452 errors.

real    0m0,905s
user    0m5,300s
sys 0m0,220s

It took less than a second to complete.

romani commented 3 months ago

What is timing of mvn sonar:sonar inside design/design-entity folder? Can you use not a sun config, but your config?

If problem is with parsing, we should be able to reproduce it by CLI. If not reproduceable, it is plugin issue.

jloisel commented 3 months ago

Our profile generates way less errors so I guess the Sun profile is a good benchmark anyway.

It's 5000ms with sonar checkstyle 10.16.0 and 500ms with 10.12.3. But again, it doesn't seem to be parsing the same xml file. When it's slow, it's always parsing the same XML file at the root of the project. When it's fast, it's parsing individual xml files inside each module target.

It's most likely sonar plugin issue as checkstyle scan is very fast on each module individually.

romani commented 3 months ago

@muhlba91, how we reproduce problem on our side? Or trace it on user side.

jloisel commented 3 months ago

I hope you can find what's wrong so we can upgrade checkstyle again.

muhlba91 commented 3 months ago

1/ could you post the contents of the target/sonar/checkstyle.xml files? 2/ this file is generated by SQ when executing checkstyle. it should correspond to your quality profile in SQ. can you verify this by randomly skimming over the XML?

btw, interestingly, from my perspective, just by looking at the command and the paths it takes the XML file from, i'd have expected the "global XML file" to be used for a while already. it does make sense to a certain point.

however, i do believe the cause is the removal of the deprecated MODULE scope.

before the deprecation the javadoc for these qualifiers read: https://javadocs.sonarsource.org/6.4/apidocs/org/sonar/api/resources/Qualifiers.html#MODULE -> Module of a multi-modules project. It's sometimes called "sub-project". Scope of modules is Scopes.PROJECT https://javadocs.sonarsource.org/6.4/apidocs/org/sonar/api/resources/Qualifiers.html#PROJECT -> Single project or root of multi-modules projects Scope is Scopes.PROJECT

now the deprecation notice is: https://javadocs.sonarsource.org/9.9.0.229/org/sonar/api/resources/Qualifiers.html#MODULE -> since 7.7 as modules doesn't exist anymore

according to this, i'd assume that modules are not supported/working at all anymore since 7.7, and there should have been an analysis change starting with SQ 7.7 already, which should not have been affected by us removing this qualifier so late.

currently, i see two options to proceed here: 1/ revert the change and rely on an unspecified, deprecated, and apparently removed qualifier where its behaviour isn't known and/or specified anymore. 2/ opening a Sonar issue (https://sonarsource.atlassian.net/projects/PLUGINAPI/issues/?filter=allissues) or posting in the community forums (https://community.sonarsource.com/).

due to the age of the deprecation notice (SQ 7.7) and the comment added by the SQ team, i somehow despise option 1. that makes it pretty unclear and error-prone as no one actually knows what the actual and expected behaviour for this qualifier is/was/will be. @jloisel you seem to have a pretty good example of the timings in your project and how this affects the analysis. would you care to open an official SQ issue and cross-reference it with this one here? otherwise, i'd take that on but i believe with your data at hand you might have more insights you can provide them with in case of questions.

romani commented 3 months ago

@muhlba91 , can you create PR with revert and let @jloisel build it, command should be shared, and try to use it on his project. If performance come back to normal, at least we will be confident in root cause.

jloisel commented 3 months ago

Let me know, I can try your custom build plugin on my sonarqube instance and run it against our code base. We have a multi-module project with 500+ modules.

I'd like you to take the action over the issue on SQ side. I'm not following actively the issue so it's better that you get to the front on it.

jloisel commented 3 months ago

Checkstyle plugin 10.12.3.

Here is an exemple checkstyle.xml from one of our modules: (design-entity module)

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" "https://checkstyle.org/dtds/configuration_1_3.dtd"><!-- Generated by Sonar --><module name="Checker"><module name="SuppressWarningsFilter" /><module name="TreeWalker"><module name="SuppressWarningsHolder"/> <module name="SuppressionCommentFilter" /></module></module>

Here is an exemple checkstyle-result.xml from one of our modules: (design-entity module)

<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="10.12.3">
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/playwright/PlaywrightConfigurationAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanUrl.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/variable/CounterVariable.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/ContainerTimeline.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/XPath2VariableExtractor.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/jmeter/ElementProp.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/ThinktimeConstantThroughput.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/HttpRequestAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanKeyValue.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/JSR223Action.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/FlowControlContainerAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/XPath1TolerantSettings.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/XmlNamespace.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/auth/HttpAuthorization.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/jmeter/CollectionProp.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanType.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/SetRuntimePropertyAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/playwright/PlaywrightSpecAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/jmeter/BoolProp.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/HttpServer.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/VirtualUser.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/RegexpVariableExtractor.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanCollection.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanRequest.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/PollQueueAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/variable/Variable.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/jmeter/JMeterAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/AssertionType.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/correlation/InHttpPostParameterName.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/server/IpSpoofingType.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/Server.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/HtmlVariableExtractor.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/variable/VariablesConfig.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/correlation/CorrelationConfig.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/jmeter/IntProp.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/VariableExtractFrom.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/playwright/PlaywrightDependency.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/ThinktimeText.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/PostProcessor.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/jmeter/plugins/JMeterPluginVersion.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/variable/SecretVariable.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/variable/RandomVariable.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/FlowControlType.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/jmeter/FloatProperty.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanAuth.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/ActionRegistrator.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/variable/package-info.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/correlation/CorrelationRule.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/correlation/InHttpQueryParameterName.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/Assertion.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/JsonVariableExtractor.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/AssertionOn.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/JSR223Script.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/IfContainerAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/auth/HttpAuthorizationConfig.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/correlation/InHttpPostParameterValue.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/WhileContainerAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/ThinktimeUniformRandom.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/WebDriverAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanVariable.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/jmeter/DoubleProp.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/sanitycheck/SanityCheckErrorLevel.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/server/IpSpoofing.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/ForEachContainerAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/jmeter/ObjProp.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/ContainerAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/correlation/InHttpHeaderValue.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanScript.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/auth/HttpKerberosAuthorization.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/PutQueueAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/AssertionMatchType.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/jmeter/StringProp.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/sanitycheck/GenericError.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/ContainerTimelineEntry.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/correlation/InHttpRequestPath.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/XPath1VariableExtractor.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/ContainerTimelineEntryType.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/LinkAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanBody.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanBodyMode.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/sanitycheck/SanityCheckConfig.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/XPath1Settings.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/VariableExtractor.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/JsonAssertion.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/LoopContainerAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanQuery.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/DebugAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/sanitycheck/SanityCheckError.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/correlation/CorrelationFramework.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/Project.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/ContainerAlgorithm.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanInfo.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/variable/ConstantVariable.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/RandomContainerAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/correlation/package-info.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/JSR223ActionType.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/AssertionOperator.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/playwright/ResourceAggregator.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/correlation/InHttpQueryParameterValue.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanFileBody.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/variable/VariableWrapper.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/ProjectType.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanEvent.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/correlation/InHttpRequestPostBody.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/SearchType.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/variable/ListVariable.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/auth/HttpNTLMAuthorization.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/variable/CSVVariable.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/AssertionNegate.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/ThinktimeConstant.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanUrlEncodedBody.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/HtmlVariableExtractorType.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/XPath1StrictSettings.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/ResponseAssertion.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/jmeter/JMeterConfig.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/JMesPathVariableExtractor.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanData.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/variable/VariableScope.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/jmeter/plugins/JMeterPlugin.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/ScriptLanguage.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/RequestUrl.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/jmeter/LongProp.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanFormDataBody.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/VirtualUserType.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/ConditionalAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/DelayAction.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanHeader.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/auth/HttpBasicAuthorization.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/correlation/InHttpHeaderName.java">
</file>
<file name="/home/ubuntu/.../design/design-entity/src/main/java/com/octoperf/entity/design/postman/PostmanItem.java">
</file>
</checkstyle>

I just have replace part of the file path by ... for clarity.

muhlba91 commented 3 months ago

@jloisel i have reverted this change in branch https://github.com/checkstyle/sonar-checkstyle/tree/revert-qualifiers.

if you checkout the branch and run mvn clean package you should have a file target/checkstyle-sonar-plugin-10.17.0-SNAPSHOT.jar which you can test to verify that this change actually is the reason.

jloisel commented 3 months ago

I have done a sonarqube analysis again with 10.16.0. The checkstyle-result.xml is quite large 700kB, while checkstyle.xml is the same. I think this explains why the analysis is slow. It seems to analyse the whole project over and over, or to accumulate results in it.

Going to run the snapshot plugin.

rnveach commented 3 months ago

checkstyle-result.xml is quite large 700kB It seems to analyse the whole project over and over, or to accumulate results in it.

If you confirm you see the same file path listed multiple times and how many duplicated times, that would confirm it is re-running the same file multiple times. Each <file tag is a file started event.

If this is the case, one temporary workaround could be to set cacheFile in Checker but I don't know how this would work, or if it does work at all in sonar's environment. I am not a sonar user or developer. https://checkstyle.org/config.html#Checker_Properties

If it is not possible to use cacheFile, then I don't think there is any temporary workaround through the checkstyle library itself. Our list of files to run against is a List, not a Set, so we don't remove duplicates if the sonar library or any other library sends us a duplicated list.

romani commented 3 months ago

@jloisel, please share results of execution on checkstyle-sonar-plugin-10.17.0-SNAPSHOT.jar from branch.

jloisel commented 3 months ago

checkstyle-sonar-plugin-10.17.0-SNAPSHOT.jar is as slow as 10.16.0:

image

No improvement.

 16:06:17.660 Checkstyle output report: /home/ubuntu/.jenkins/workspace/backend-sonarqube/target/sonar/checkstyle-result.xml
16:06:17.662 Checkstyle configuration: /home/ubuntu/.jenkins/workspace/backend-sonarqube/target/sonar/checkstyle.xml
16:06:17.663 Checkstyle charset: UTF-8
16:06:22.974 Sensor CheckstyleSensor [checkstyle] (done) | time=5314ms

There is no duplicate in checkstyle-result.xml. However, it contains all the Java files of the project. I believe the analysis is ran against all Java files for each maven sub-module.

muhlba91 commented 3 months ago

Looking at it more closely, it might be related to the upgrade from sonar-api 7 to 9. The output report being logged in the previous images is from

https://github.com/checkstyle/sonar-checkstyle/blob/23d669d31cb08a0eb12422897373d1ff92dd165c/src/main/java/org/sonar/plugins/checkstyle/CheckstyleExecutor.java#L97

. that xml report is located with filesystem.workdir, see https://github.com/checkstyle/sonar-checkstyle/blob/23d669d31cb08a0eb12422897373d1ff92dd165c/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java#L130

. The filesystem is injected from Sonarqube core, and might have changed its behavior for multi module maven projects between 7 and 9.

@jloisel i have force pushed (!!!) to the same branch as before. would you be able to build and test that one again?

i have reverted the annotation that was deprecated and is responsible for injecting the FileSystem. besides the qualifiers, which we ruled out by now, this is the other major deprecation they introduced in 7.7. it would be interesting to verify whether this is the reason for the slowdown. could you also please have a look at the paths logged for where the config and results are stored?

jloisel commented 3 months ago

Ok let me try it again. I have tested 10.14.1 too, and it's also slow.

UPDATE: with your latest changes, on 10.17-snapshot, it's fast again.

image

For example:

Sensor CheckstyleSensor [checkstyle]
Checkstyle output report: /home/ubuntu/.jenkins/workspace/backend-sonarqube/design/design-entity/target/sonar/checkstyle-result.xml
Checkstyle configuration: /home/ubuntu/.jenkins/workspace/backend-sonarqube/design/design-entity/target/sonar/checkstyle.xml
Checkstyle charset: UTF-8
Sensor CheckstyleSensor [checkstyle] (done) | time=61ms

So your changes fixed the issue :)

muhlba91 commented 3 months ago

@jloisel thank you! 😃 i also just got the confirmation from sonar in their forums: https://community.sonarsource.com/t/replacement-for-deprecated-org-sonar-api-batch-scannerside/115854/4

i'd very much like to test if a migration to ProjectSensor would also solve the performance to keep the codebase deprecation free for now. if you are up for it, i have force pushed again on that branch with this change. if this also solves the performance, i'd opt for applying this change; if not, then i'd revert the ScannerSide change with the note that we know already this change has to happen at some point once SQ drops support for modules entirely in their codebase.

jloisel commented 3 months ago

Hi, It's still fast with the latest changes you provided:

image

:+1:

muhlba91 commented 3 months ago

10.17.0 is on its way including this change - it will be visible in the marketplace once this PR is merged: https://github.com/SonarSource/sonar-update-center-properties/pull/551

NoSugarCoffee commented 3 months ago

We have upgraded to Checkstyle 10.16.0 and it's very slow too for a while now. Takes about 40min (was 12min before) sonar analysis alone, due to checkstyle taking 5+sec per maven module. It used to be less than 1sec per module. We have 500+ maven modules in our project.

We have Sonarqube 9.9.5 Community Edition.

same version and the same issue.

I saw the right version 10.17.0 based on the above discussion. Thanks @muhlba91 and @jloisel

muhlba91 commented 3 months ago

@jloisel @Bananeweizen @ArnaudAndr @NoSugarCoffee can you confirm that 10.17.0 is solving this problem for you, and we can close this isse? 😃

NoSugarCoffee commented 3 months ago

My side. It works after using 10.17.0. From the log. It seems that the sonar-checkstyle changes the behavior from running each module to the whole project.

Following is the analysis log of the same project and the same command image

muhlba91 commented 3 months ago

@NoSugarCoffee thank you for confirming that this solves the slowdown.

the different analysis behavior you see now is expected. as SQ clarified the module approach is deprecated and will be removed and entirely replaced by a project-only approach.

Bananeweizen commented 2 months ago

Unfortunately it took a while in my company to get a centralized update, but I can also confirm now that the execution time is good again. Thanks for taking care of this.

romani commented 2 months ago

@muhlba91 , should we close issue?

muhlba91 commented 2 months ago

yes, based on the received feedback we can assume this is fixed.