Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-825

Unnecessary performance overhead in MongoMK's calculation of keys for the nodeCache, nodeChildrenCache

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.7
    • 0.16
    • mongomk
    • None

    Description

      The key of MongoMK.nodeCache and nodeChildrenCache is currently a String, whose evaluation is somewhat expensive:

      path + "@" + rev
      

      In the above code, "rev.toString()" internally creates another StringBuilder to generate another intermediate string. The attached screenshot shows that around 5% of profiling time within "MongoMK.getNode()" is wasted in order to calculate the caching key. Other methods are also affected.

      A simple way to improve this is to reuse a single StringBuilder for the key, as such:

      StringBuilder sb = new StringBuilder();
      sb.append(path);
      sb.append("@");
      rev.appendTo(sb);
      

      A better way would probably be to wrap "path" and "rev" in another re-usable "NodeRev" object to be used instead of using two references "path" and "rev". The "NodeRev" object would provide appropriate equals() and hashCode() implementations.

      Attachments

        1. MongoMK.nodeCache.png
          83 kB
          Lukas Eder

        Activity

          People

            mreutegg Marcel Reutegger
            lukas.eder Lukas Eder
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: