lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Walter Underwood (JIRA)" <>
Subject [jira] [Commented] (LUCENE-4930) Lucene's use of WeakHashMap at index time prevents full use of cores on some multi-core machines, due to contention
Date Fri, 12 Apr 2013 17:56:16 GMT


Walter Underwood commented on LUCENE-4930:

Running 6b14 is a very dangerous thing. Anyone who can send an HTTP request to your servers
can put a  thread into an infinite loop. 
> Lucene's use of WeakHashMap at index time prevents full use of cores on some multi-core
machines, due to contention
> -------------------------------------------------------------------------------------------------------------------
>                 Key: LUCENE-4930
>                 URL:
>             Project: Lucene - Core
>          Issue Type: Improvement
>          Components: core/index
>    Affects Versions: 4.2
>         Environment: Dell blade system with 16 cores
>            Reporter: Karl Wright
>         Attachments: thread_dump.txt
> Our project is not optimally using full processing power during under indexing load on
Lucene 4.2.0.  The reason is the AttributeSource.addAttribute() method, which goes through
a WeakHashMap synchronizer, which is apparently single-threaded for a significant amount of
time.  Have a look at the following trace:
> "pool-1-thread-28" prio=10 tid=0x00007f47fc104800 nid=0x672b waiting for monitor entry
>    java.lang.Thread.State: BLOCKED (on object monitor)
>         at java.lang.ref.ReferenceQueue.poll(
>         - waiting to lock <0x00000005c5cd9988> (a java.lang.ref.ReferenceQueue$Lock)
>         at org.apache.lucene.util.WeakIdentityMap.reap(
>         at org.apache.lucene.util.WeakIdentityMap.get(
>         at org.apache.lucene.util.AttributeSource$AttributeFactory$DefaultAttributeFactory.getClassForInterface(
>         at org.apache.lucene.util.AttributeSource$AttributeFactory$DefaultAttributeFactory.createAttributeInstance(
>         at org.apache.lucene.util.AttributeSource.addAttribute(
>         at org.apache.lucene.index.DocInverterPerField.processFields(
>         at org.apache.lucene.index.DocFieldProcessor.processDocument(
>         at org.apache.lucene.index.DocumentsWriterPerThread.updateDocument(
>         at org.apache.lucene.index.DocumentsWriter.updateDocument(
>         at org.apache.lucene.index.IndexWriter.updateDocument(
>         at org.apache.lucene.index.IndexWriter.addDocument(
>         at org.apache.lucene.index.IndexWriter.addDocument(
> …
> We’ve had to make significant changes to the way we were indexing in order to not hit
this issue as much, such as indexing using TokenStreams which we reuse, when it would have
been more convenient to index with just tokens.  (The reason is that Lucene internally creates
TokenStream objects when you pass a token array to IndexableField, and doesn’t reuse them,
and the addAttribute() causes massive contention as a result.)  However, as you can see from
the trace above, we’re still running into contention due to other addAttribute() method
calls that are buried deep inside Lucene.
> I can see two ways forward.  Either not use WeakHashMap or use it in a more efficient
way, or make darned sure no addAttribute() calls are done in the main code indexing execution
path.  (I think it would be easy to fix DocInverterPerField in that way, FWIW.  I just don’t
know what we’ll run into next.)

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:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message