Jackrabbit Content Repository
  1. Jackrabbit Content Repository
  2. JCR-1251

DescendantSelfAxisQuery creates too many object instances

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4
    • Component/s: jackrabbit-core, query
    • Labels:
      None

      Description

      In DescendantSelfAxisQuery.DescendantSelfAxisScorer.isValid() there is an ArrayList and an Integer instance created on every call. Since this method gets called really often during queries the object creation/gc affects performance.

      1. JCR-1251.patch
        1 kB
        Marcel Reutegger
      2. DescendantSelfAxisQuery-patch.txt
        2 kB
        Christoph Kiehl

        Activity

        Hide
        Christoph Kiehl added a comment -

        I'm getting a performance boost of about 40% on big indexes (about 1000000 nodes) using plain arrays instead of ArrayLists because this avoids a lot of object creation. If no one objects I'm going to commit this.

        Show
        Christoph Kiehl added a comment - I'm getting a performance boost of about 40% on big indexes (about 1000000 nodes) using plain arrays instead of ArrayLists because this avoids a lot of object creation. If no one objects I'm going to commit this.
        Hide
        Ard Schrijvers added a comment -

        40% !! That is quite some performance gain, very nice. I did see quite some CPU time in array list calls during DescendantSelfAxis tests (11% or something I saw was spend in the init() only).

        +1 obviously!

        Show
        Ard Schrijvers added a comment - 40% !! That is quite some performance gain, very nice. I did see quite some CPU time in array list calls during DescendantSelfAxis tests (11% or something I saw was spend in the init() only). +1 obviously!
        Hide
        Ard Schrijvers added a comment -

        By the way: do not think you should commit the patch like it is now : Arrays.copyOf is not supported for java < 1.6. Use System.arraycopy.

        Furthermore, I have tested as well, and performance gain is indeed very large! Nice improvement!

        Show
        Ard Schrijvers added a comment - By the way: do not think you should commit the patch like it is now : Arrays.copyOf is not supported for java < 1.6. Use System.arraycopy. Furthermore, I have tested as well, and performance gain is indeed very large! Nice improvement!
        Hide
        Christoph Kiehl added a comment -

        Ah, you are certainly right. I'll use System.arraycopy instead. Thanks for the pointer!

        Show
        Christoph Kiehl added a comment - Ah, you are certainly right. I'll use System.arraycopy instead. Thanks for the pointer!
        Hide
        Marcel Reutegger added a comment -

        +1

        Show
        Marcel Reutegger added a comment - +1
        Hide
        Christoph Kiehl added a comment -

        Committed in rev. 601562

        Show
        Christoph Kiehl added a comment - Committed in rev. 601562
        Hide
        Marcel Reutegger added a comment -

        Hmm, I think we can even get rid of initializing the array on each validation. See patch.

        btw. I also removed unused import statements.

        Show
        Marcel Reutegger added a comment - Hmm, I think we can even get rid of initializing the array on each validation. See patch. btw. I also removed unused import statements.
        Hide
        Christoph Kiehl added a comment -

        Well spotted! I observed another gain of about 7% on my machine with about 100.000 documents using your patch. So definitely +1

        Show
        Christoph Kiehl added a comment - Well spotted! I observed another gain of about 7% on my machine with about 100.000 documents using your patch. So definitely +1
        Hide
        Marcel Reutegger added a comment -

        Committed the patch in revision: 602856

        Show
        Marcel Reutegger added a comment - Committed the patch in revision: 602856

          People

          • Assignee:
            Christoph Kiehl
            Reporter:
            Christoph Kiehl
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development