Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-3381

Performance Issue when computing the flow of an expression

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.7
    • Component/s: Symbolic Execution
    • Labels:

      Description

      Opening the file /java-checks-test-sources/src/main/java/checks/AssertionInTryCatchCheck.java in Intellij Idea with SonarLint and the rule S2583(ConditionalUnreachableCodeCheck) activated (which is by default), freeze the IDE during 10 seconds (or forever with the default JVM memory configuration). Without the ConditionalUnreachableCodeCheck rule, SonarLint analyzes the file in 200 ms.

      Running the rule ConditionalUnreachableCodeCheck on the file AssertionInTryCatchCheck.java takes 8 seconds.

        @Test
        void test_performance() {
          JavaCheckVerifier.newVerifier()
            .onFile(testSourcesPath("checks/AssertionInTryCatchCheck.java"))
            .withCheck(new ConditionalUnreachableCodeCheck())
            .verifyIssues();
        }
      

      The rule finds in few milliseconds 0 "true evaluations" and 32 "false evaluations".
      And spend all the time (5 seconds) in atof.flowForExpression(condition) that return 134'784 "Flow" used to report one issue at line 110 using one flow.

      if (something()) {
      

      flowForExpression(Tree expression) collects 32 nodes in 1 ms and 5 seconds in collectFlow(nodes)

      Note: By forcing the parameter skipExceptionMessages=true in the call flow(...,true) (FlowComputation.java:118)
      it reduces the collectFlow time from 5 seconds to 105 ms.

        Attachments

          Activity

            People

            • Assignee:
              alban.auzeill Alban Auzeill
              Reporter:
              alban.auzeill Alban Auzeill
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved: