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

Reply via email to