jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ard Schrijvers (JIRA)" <j...@apache.org>
Subject [jira] Commented: (JCR-1213) UUIDDocId cache does not work properly because of weakReferences in combination with new instance for combined indexreader
Date Tue, 20 Nov 2007 18:21:43 GMT

    [ https://issues.apache.org/jira/browse/JCR-1213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12543985
] 

Ard Schrijvers commented on JCR-1213:
-------------------------------------

Follow up:

I have been trying to cache docNumbers with respect to their IndexSegments, which obviously
do change less frequently.  Caching based on an entire CachingMultiReader is trivial, but
also, the performance gain is to small, since the multiReader changes to  frequently.

But, I am having difficulties somebody might be able to help me with

Bottom line is, we do not want to cache based on the entire CachingMultiReader, but on its
segments it consists of. Now, I build (hacked for the time being)  something that in DocId.UUIDDocId
I keep track of the segment reference through a WeakReference. But....as I didn't see behavior
I was expecting, I found another difficulty:

The multiReader which is created in MultiIndex is a CachingMultiReader consisting of ReadOnlyIndexReader's.
When something changed in one of the indexes, a new multiReader is constructed....but instead
of reusing the non-changed ReadOnlyIndexReader instances, every ReadOnlyIndexReader is re-constructed
(not the shared/caching reader they consist of though ) , but, since the instances our multiReader
consists of are recreated, my WeakReferences based on segment instances are useless. 

So, instead of using a WeakReference on the multiReader segments, I could get the sharedReader
instance out of it, but this means casting and adding methods, something we really do not
want of course (and i am not sure if the BitSet keeing track of deleted might have changed
without  the sharedReader being changed (  to be honest, I cannot yet grasp the big picture
about keeping track of the deleted bitset )  ).

So, does anybody have an idea how we might be able to have in MultiIndex.getIndexReader()
 only new instances of the ReadOnlyIndexReaders which actually changed...Or is this not an
option? I did try to add it to the AbstractIndex to check wether there was already an instance
of ReadOnlyIndexReader but then I get  AlreadyClosedException in lucene. 

I can make another JIRA issue for it if others think it might be valuable and not part of
this issue. WDOT?

> UUIDDocId cache does not work properly because of weakReferences in combination with
new instance for combined indexreader 
> ---------------------------------------------------------------------------------------------------------------------------
>
>                 Key: JCR-1213
>                 URL: https://issues.apache.org/jira/browse/JCR-1213
>             Project: Jackrabbit
>          Issue Type: Improvement
>          Components: query
>    Affects Versions: 1.3.3
>            Reporter: Ard Schrijvers
>             Fix For: 1.4
>
>
> Queries that use ChildAxisQuery or DescendantSelfAxisQuery make use of getParent() functions
to know wether the parents are correct and if the result is allowed. The getParent() is called
recursively for every hit, and can become very expensive. Hence, in DocId.UUIDDocId, the parents
are cached. 
> Currently,  docId.UUIDDocId's are cached by having a WeakRefence to the CombinedIndexReader,
but, this CombinedIndexReader is recreated all the time, implying that a gc() is allowed to
remove the 'expensive' cache.
> A much better solution is to not have a weakReference to the CombinedIndexReader, but
to a reference of each indexreader segment. This means, that in getParent(int n) in SearchIndex
the return 
> return id.getDocumentNumber(this) needs to be replaced by return id.getDocumentNumber(subReaders[i]);
and something similar in CachingMultiReader. 
> That is all. Obviously, when a node/property is added/removed/changed, some parts of
the cached DocId.UUIDDocId will be invalid, but mainly small indexes are updated frequently,
which obviously are less expensive to recompute.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message