You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Lukas Eder (JIRA)" <ji...@apache.org> on 2013/05/16 15:21:15 UTC

[jira] [Created] (OAK-825) Unnecessary performance overhead in MongoMK's calculation of keys for the nodeCache, nodeChildrenCache

Lukas Eder created OAK-825:
------------------------------

             Summary: Unnecessary performance overhead in MongoMK's calculation of keys for the nodeCache, nodeChildrenCache
                 Key: OAK-825
                 URL: https://issues.apache.org/jira/browse/OAK-825
             Project: Jackrabbit Oak
          Issue Type: Bug
          Components: mongomk
    Affects Versions: 0.7
            Reporter: Lukas Eder
         Attachments: MongoMK.nodeCache.png

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

{code}
path + "@" + rev
{code}

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:

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

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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira