-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove synchronization in SegmentReader.isDeleted [LUCENE-1329] #2406
Comments
Jason Rutherglen (migrated from JIRA) lucene-1329.patch |
Michael McCandless (@mikemccand) (migrated from JIRA) Jason, have you run any scale tests (w/ many threads) to confirm whether volatile is faster than using synchronized, for this case? I'm especially curious on what happens with JRE 1.4, since with this patch it is now synchronized and volatile. I think we should, at least in addition but perhaps instead, create a way to open a read-only IndexReader. This way no synchronization nor volatile would be necessary when accessing deletedDocs. |
Sanne Grinovero (migrated from JIRA) Adding a readonly IndexReader would be really great, I'm contributing some code to Hibernate Search (integration of Lucene and Hibernate) and that |
Yonik Seeley (@yonik) (migrated from JIRA)
Right... a volatile is still "half" a synchronized in many ways, and gets more expensive as you add more cores. IAFAIK It's also something you won't see with a profiler because it involves cache flushes, not explicit high level blocking. |
Yonik Seeley (@yonik) (migrated from JIRA) Once we have a read-only IndexReader, if we still want the deleting-reader then we could also weaken the semantics of deleteDocument such that applications would need to synchronize themselves to guarantee visibility to another thread. We could safely do this for a deleting-reader by pre-allocating the BitVector objects, thus eliminating the possibility of a thread seeing a partially constructed object. |
Michael McCandless (@mikemccand) (migrated from JIRA) I took a first cut at creating an explicit read only IndexReader I added "boolean readOnly" to 3 of the IndexReader open methods, and reopen() also preserves readOnly-ness, and I fixed merging to open readOnly
I didn't do this one yet ... it makes me a bit nervous because it Really, I think we want to default IndexReader.open to be |
Yonik Seeley (@yonik) (migrated from JIRA)
Right, which is why I said it was for a "deleting-reader" (which presumes the existence of read-only-readers). |
Michael McCandless (@mikemccand) (migrated from JIRA) I'd like to get this (read-only IndexReader) into 2.4. |
Michael McCandless (@mikemccand) (migrated from JIRA) Attached new rev of this patch. I think it's ready to commit. I'll wait a few days. Changes:
|
Eks Dev (migrated from JIRA) Mike, did someone measure what this brings? This practically reduces need to have many IndexReader-s in MT setup when Index is used in read only case. |
Michael McCandless (@mikemccand) (migrated from JIRA)
I don't think so – I haven't yet tested how much of a bottleneck this was / how much it helps that isDeleted is no longer synchronized.
I really want to get Lucene to this point, but I fear #1828 may still stand in the way since many threads can pile up when accessing the same file. Sadly, an optimized index exacerbates the situation (the polar opposite of what you'd expect when optimizing an index). On every platform except Windows, this patch combined with NIOFSDirectory ought to solve all known search-time bottlenecks. |
Eks Dev (migrated from JIRA) ok, I see, thanks. We have seen performance drop for RAM based index when we switched to MT setup with shared IndexReader, I am not yet sure what is the reason for it, problems in our code or this is indeed related to lucene. I am talking about 25-30% drop on 3 Threads on 4-Core CPU. Must measure it properly... |
Michael McCandless (@mikemccand) (migrated from JIRA) I just committed this. Thanks Jason! |
Removes SegmentReader.isDeleted synchronization by using a volatile deletedDocs variable on Java 1.5 platforms. On Java 1.4 platforms synchronization is limited to obtaining the deletedDocs reference.
Migrated from LUCENE-1329 by Jason Rutherglen, resolved Aug 23 2008
Attachments: lucene-1329.patch, LUCENE-1329.patch (versions: 2)
The text was updated successfully, but these errors were encountered: