OpenJPA
  1. OpenJPA
  2. OPENJPA-1741

Unecessary class load attempts when parsing JPQL

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.2.2, 2.0.0
    • Fix Version/s: None
    • Component/s: query
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      When parsing JPQL, JPQLExpressionBuilder.getPathOrConstant() tries to determine if a token is a java class or enum by doing a class load (via QueryImpl.classForName()). The same token will be tried as often as it appears in the query. It might be better to

      1) cache the results
      2) avoid the lookup if the token is a known variable name

      1. cache-class-load-attempts.patch
        2 kB
        David Minor
      2. skip-known-variables.patch
        0.8 kB
        David Minor
      3. only-load-uppercase-java-lang.patch
        0.7 kB
        David Minor

        Activity

        Hide
        David Minor added a comment -

        Attached a patch to cache class load attempts in a HashMap, and return the cached results for future identical class loads.

        Show
        David Minor added a comment - Attached a patch to cache class load attempts in a HashMap, and return the cached results for future identical class loads.
        Hide
        David Minor added a comment -

        Added patch to skip known variables, rather than attempting to load them as a class.

        Show
        David Minor added a comment - Added patch to skip known variables, rather than attempting to load them as a class.
        Hide
        David Minor added a comment -

        Attached a patch to limit class load attempts for the java.lang package. After attempting to load a token by itself, and then with the query object's package prepended, QueryImpl.classForName() currently attempts to load the token with 'java.lang' prepended.

        This patch makes the assumption that there are no classes in java.lang starting with a lower case letter, and skips the load attempt.

        Show
        David Minor added a comment - Attached a patch to limit class load attempts for the java.lang package. After attempting to load a token by itself, and then with the query object's package prepended, QueryImpl.classForName() currently attempts to load the token with 'java.lang' prepended. This patch makes the assumption that there are no classes in java.lang starting with a lower case letter, and skips the load attempt.
        Hide
        Rick Curtis added a comment -

        With the attached patches are you seeing a measurable performance improvement?

        Show
        Rick Curtis added a comment - With the attached patches are you seeing a measurable performance improvement?
        Hide
        David Minor added a comment -

        Yes. In periodic thread dumps of our production JVM, the number of OpenJPA threads in getPathOrConstant() went from 25% of OpenJPA threads to 3%.

        Show
        David Minor added a comment - Yes. In periodic thread dumps of our production JVM, the number of OpenJPA threads in getPathOrConstant() went from 25% of OpenJPA threads to 3%.
        Hide
        Rick Curtis added a comment -

        Closing this JIRA as I don't expect that we're ever going to make this change.

        Show
        Rick Curtis added a comment - Closing this JIRA as I don't expect that we're ever going to make this change.

          People

          • Assignee:
            Rick Curtis
            Reporter:
            David Minor
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development