You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Alex Parvulescu (Created) (JIRA)" <ji...@apache.org> on 2012/03/13 23:18:42 UTC

[jira] [Created] (JCR-3257) ItemManager cache access tweaks

ItemManager cache access tweaks
-------------------------------

                 Key: JCR-3257
                 URL: https://issues.apache.org/jira/browse/JCR-3257
             Project: Jackrabbit Content Repository
          Issue Type: Improvement
          Components: jackrabbit-core
            Reporter: Alex Parvulescu


I started with #evictItem but I ended up doing some more tiny changes overall:

 - #evictItem: we can safely refactor the #get -> #remove into a simple #remove:

It appears that the check "cached == data" only applies to shareable nodes. I ran the entire jacorabbit-core test suite and the check failed 9 times, out of which 3 were related to shareable nodes and the other 6 were just comparing to null, in which case we can safely evict the value.

So if we refactor the method to be consistent with #cacheItem, we can safely remove the "==" check. The shareableNodesCache has the shareable nodes info, itemCache everything else.

- #cacheItem doesn't need to check if the key exists, #put already returns the info

- #itemDestroyed does not need to synchronize on itemCache as #evictItems already does that

- ShareableNodesCache#evictAll doesn't need to be synchronized - that is already covered by #evictItems with the synchronization on itemCache

patch follows shortly

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (JCR-3257) ItemManager cache access tweaks

Posted by "Stefan Guggisberg (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13229105#comment-13229105 ] 

Stefan Guggisberg commented on JCR-3257:
----------------------------------------

ItemManager is at the very core of jackrabbit. unless there's a real issue i'd rather not touch it. 
                
> ItemManager cache access tweaks
> -------------------------------
>
>                 Key: JCR-3257
>                 URL: https://issues.apache.org/jira/browse/JCR-3257
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>          Components: jackrabbit-core
>            Reporter: Alex Parvulescu
>         Attachments: JCR-3257.patch
>
>
> I started with #evictItem but I ended up doing some more tiny changes overall:
>  - #evictItem: we can safely refactor the #get -> #remove into a simple #remove:
> It appears that the check "cached == data" only applies to shareable nodes. I ran the entire jacorabbit-core test suite and the check failed 9 times, out of which 3 were related to shareable nodes and the other 6 were just comparing to null, in which case we can safely evict the value.
> So if we refactor the method to be consistent with #cacheItem, we can safely remove the "==" check. The shareableNodesCache has the shareable nodes info, itemCache everything else.
> - #cacheItem doesn't need to check if the key exists, #put already returns the info
> - #itemDestroyed does not need to synchronize on itemCache as #evictItems already does that
> - ShareableNodesCache#evictAll doesn't need to be synchronized - that is already covered by #evictItems with the synchronization on itemCache
> patch follows shortly

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (JCR-3257) ItemManager cache access tweaks

Posted by "Stefan Guggisberg (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-3257?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Guggisberg resolved JCR-3257.
------------------------------------

    Resolution: Won't Fix

there's no real issue at hand and OTOH there's a significant risk of causing regressions.

resolving as 'won't fix'.
                
> ItemManager cache access tweaks
> -------------------------------
>
>                 Key: JCR-3257
>                 URL: https://issues.apache.org/jira/browse/JCR-3257
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>          Components: jackrabbit-core
>            Reporter: Alex Parvulescu
>         Attachments: JCR-3257.patch
>
>
> I started with #evictItem but I ended up doing some more tiny changes overall:
>  - #evictItem: we can safely refactor the #get -> #remove into a simple #remove:
> It appears that the check "cached == data" only applies to shareable nodes. I ran the entire jacorabbit-core test suite and the check failed 9 times, out of which 3 were related to shareable nodes and the other 6 were just comparing to null, in which case we can safely evict the value.
> So if we refactor the method to be consistent with #cacheItem, we can safely remove the "==" check. The shareableNodesCache has the shareable nodes info, itemCache everything else.
> - #cacheItem doesn't need to check if the key exists, #put already returns the info
> - #itemDestroyed does not need to synchronize on itemCache as #evictItems already does that
> - ShareableNodesCache#evictAll doesn't need to be synchronized - that is already covered by #evictItems with the synchronization on itemCache
> patch follows shortly

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (JCR-3257) ItemManager cache access tweaks

Posted by "Alex Parvulescu (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13229101#comment-13229101 ] 

Alex Parvulescu commented on JCR-3257:
--------------------------------------

> what issue do you want to address with your patch? 

The #cacheItem (PUT) should be mirrored by the  #evictItem (REMOVE) operation. 

> if there's a performance issue can you please share some benchmark results?
No performance issue, I found this while I was investigating something else.

If you take a quick look at the code [0] you'll see that #cacheItem makes some assumptions [1] about the cached items that #evictItem effectively ignores. 
If we apply the same rules, then we can optimize #evictItem and save a key lookup operation for each remove and an actual #remove operation for shareable nodes.

Do you think that this patch is not optimal?

[0] https://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
[1] shareable nodes ( #.isNode() &&  ".getPrimaryParentId() != null) exist only in shareableNodesCache
                
> ItemManager cache access tweaks
> -------------------------------
>
>                 Key: JCR-3257
>                 URL: https://issues.apache.org/jira/browse/JCR-3257
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>          Components: jackrabbit-core
>            Reporter: Alex Parvulescu
>         Attachments: JCR-3257.patch
>
>
> I started with #evictItem but I ended up doing some more tiny changes overall:
>  - #evictItem: we can safely refactor the #get -> #remove into a simple #remove:
> It appears that the check "cached == data" only applies to shareable nodes. I ran the entire jacorabbit-core test suite and the check failed 9 times, out of which 3 were related to shareable nodes and the other 6 were just comparing to null, in which case we can safely evict the value.
> So if we refactor the method to be consistent with #cacheItem, we can safely remove the "==" check. The shareableNodesCache has the shareable nodes info, itemCache everything else.
> - #cacheItem doesn't need to check if the key exists, #put already returns the info
> - #itemDestroyed does not need to synchronize on itemCache as #evictItems already does that
> - ShareableNodesCache#evictAll doesn't need to be synchronized - that is already covered by #evictItems with the synchronization on itemCache
> patch follows shortly

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (JCR-3257) ItemManager cache access tweaks

Posted by "Alex Parvulescu (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-3257?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alex Parvulescu updated JCR-3257:
---------------------------------

    Attachment: JCR-3257.patch

feedback welcome
                
> ItemManager cache access tweaks
> -------------------------------
>
>                 Key: JCR-3257
>                 URL: https://issues.apache.org/jira/browse/JCR-3257
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>          Components: jackrabbit-core
>            Reporter: Alex Parvulescu
>         Attachments: JCR-3257.patch
>
>
> I started with #evictItem but I ended up doing some more tiny changes overall:
>  - #evictItem: we can safely refactor the #get -> #remove into a simple #remove:
> It appears that the check "cached == data" only applies to shareable nodes. I ran the entire jacorabbit-core test suite and the check failed 9 times, out of which 3 were related to shareable nodes and the other 6 were just comparing to null, in which case we can safely evict the value.
> So if we refactor the method to be consistent with #cacheItem, we can safely remove the "==" check. The shareableNodesCache has the shareable nodes info, itemCache everything else.
> - #cacheItem doesn't need to check if the key exists, #put already returns the info
> - #itemDestroyed does not need to synchronize on itemCache as #evictItems already does that
> - ShareableNodesCache#evictAll doesn't need to be synchronized - that is already covered by #evictItems with the synchronization on itemCache
> patch follows shortly

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (JCR-3257) ItemManager cache access tweaks

Posted by "Stefan Guggisberg (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13229120#comment-13229120 ] 

Stefan Guggisberg commented on JCR-3257:
----------------------------------------

> Not wanting to touch the code is perfectly understandable. I was hoping for at least a code review.

while the changes do look harmless i'd have to invest a significant amount of time to analyze and
study the potential impact. i currently don't have the time, sorry. 
                
> ItemManager cache access tweaks
> -------------------------------
>
>                 Key: JCR-3257
>                 URL: https://issues.apache.org/jira/browse/JCR-3257
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>          Components: jackrabbit-core
>            Reporter: Alex Parvulescu
>         Attachments: JCR-3257.patch
>
>
> I started with #evictItem but I ended up doing some more tiny changes overall:
>  - #evictItem: we can safely refactor the #get -> #remove into a simple #remove:
> It appears that the check "cached == data" only applies to shareable nodes. I ran the entire jacorabbit-core test suite and the check failed 9 times, out of which 3 were related to shareable nodes and the other 6 were just comparing to null, in which case we can safely evict the value.
> So if we refactor the method to be consistent with #cacheItem, we can safely remove the "==" check. The shareableNodesCache has the shareable nodes info, itemCache everything else.
> - #cacheItem doesn't need to check if the key exists, #put already returns the info
> - #itemDestroyed does not need to synchronize on itemCache as #evictItems already does that
> - ShareableNodesCache#evictAll doesn't need to be synchronized - that is already covered by #evictItems with the synchronization on itemCache
> patch follows shortly

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (JCR-3257) ItemManager cache access tweaks

Posted by "Stefan Guggisberg (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13229091#comment-13229091 ] 

Stefan Guggisberg commented on JCR-3257:
----------------------------------------

what issue do you want to address with your patch? 

if there's a performance issue can you please share some benchmark results?
                
> ItemManager cache access tweaks
> -------------------------------
>
>                 Key: JCR-3257
>                 URL: https://issues.apache.org/jira/browse/JCR-3257
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>          Components: jackrabbit-core
>            Reporter: Alex Parvulescu
>         Attachments: JCR-3257.patch
>
>
> I started with #evictItem but I ended up doing some more tiny changes overall:
>  - #evictItem: we can safely refactor the #get -> #remove into a simple #remove:
> It appears that the check "cached == data" only applies to shareable nodes. I ran the entire jacorabbit-core test suite and the check failed 9 times, out of which 3 were related to shareable nodes and the other 6 were just comparing to null, in which case we can safely evict the value.
> So if we refactor the method to be consistent with #cacheItem, we can safely remove the "==" check. The shareableNodesCache has the shareable nodes info, itemCache everything else.
> - #cacheItem doesn't need to check if the key exists, #put already returns the info
> - #itemDestroyed does not need to synchronize on itemCache as #evictItems already does that
> - ShareableNodesCache#evictAll doesn't need to be synchronized - that is already covered by #evictItems with the synchronization on itemCache
> patch follows shortly

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (JCR-3257) ItemManager cache access tweaks

Posted by "Alex Parvulescu (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13229107#comment-13229107 ] 

Alex Parvulescu commented on JCR-3257:
--------------------------------------

> ItemManager is at the very core of jackrabbit. unless there's a real issue i'd rather not touch it.
That's why I submitted the patch, I think having the put and remove operation mirroring each other is important as it relates to the cache efficiency.

Not wanting to touch the code is perfectly understandable. I was hoping for at least a code review.

Feel free to close the issue, no worries.
                
> ItemManager cache access tweaks
> -------------------------------
>
>                 Key: JCR-3257
>                 URL: https://issues.apache.org/jira/browse/JCR-3257
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>          Components: jackrabbit-core
>            Reporter: Alex Parvulescu
>         Attachments: JCR-3257.patch
>
>
> I started with #evictItem but I ended up doing some more tiny changes overall:
>  - #evictItem: we can safely refactor the #get -> #remove into a simple #remove:
> It appears that the check "cached == data" only applies to shareable nodes. I ran the entire jacorabbit-core test suite and the check failed 9 times, out of which 3 were related to shareable nodes and the other 6 were just comparing to null, in which case we can safely evict the value.
> So if we refactor the method to be consistent with #cacheItem, we can safely remove the "==" check. The shareableNodesCache has the shareable nodes info, itemCache everything else.
> - #cacheItem doesn't need to check if the key exists, #put already returns the info
> - #itemDestroyed does not need to synchronize on itemCache as #evictItems already does that
> - ShareableNodesCache#evictAll doesn't need to be synchronized - that is already covered by #evictItems with the synchronization on itemCache
> patch follows shortly

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira