lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Engels" <reng...@ix.netcom.com>
Subject RE: major searching performance improvement
Date Thu, 26 May 2005 02:24:08 GMT
Ok. Attached are the updated files. I also forgot some of the changed files
the first time around (CompoundFileReader also had synchronization that
needed to be removed).

Since I am working off the 1.4 codebase, I needed to modify FSDirectory,
since most of the methods are private and/or final. I don't have the time to
port to 1.9 at the moment, but maybe someone else does.

Some "benchmarks" using our "search server", which contains 1 million
generated documents, each with 10 fields, and a total index size of 340mb.

The client test creates 16 threads, where each thread does 20 searches (via
TCP to the server) on a random field & word, returning a maximum of 500
documents. I started the server under the 3 different configurations, and
ran the client test 5 times (without restarting the server).

The BEST times for each configuration (the client code is identical in all
cases).

Using the standard FS Directory with no changes:

84375 FindPerformanceTest : 17877010 hits in 84297 ms
0 FindPerformanceTest : 320 searches in 84297 ms, avg = 263
0 FindPerformanceTest : response time: min = 47, max = 48781, avg = 2555

Using the standard FS Directory with
'SegmentReader/FieldsReader/CompoundFileReader' concurrency changes:

31437 FindPerformanceTest : 19148916 hits in 31375 ms
0 FindPerformanceTest : 320 searches in 31375 ms, avg = 98
0 FindPerformanceTest : response time: min = 140, max = 3125, avg = 1504

Using the the NioFSDirectory with block size of 64k, and cache % of 30:

21031 FindPerformanceTest : 19558942 hits in 20938 ms
0 FindPerformanceTest : 320 searches in 20938 ms, avg = 65
0 FindPerformanceTest : response time: min = 31, max = 5890, avg = 922

Some notes...

1) my machine is relatively slow, only has a single processor, and was
running both the client "test" and the "search server" and becomes CPU bound
during concurrency. On a faster machine the avg response time went from 45ms
to 24ms using the concurrency and caching modifications.

2) you probably noticed that that the avg time is less than the minimum time
in some cases. This is due to thread switching, and calculated individual
response times. The avg time uses only the start time, end time, and number
of searches.

3) I would expect a Linux/Unix machine to show even greater improvement
since there will be less contention for the FileChannel.

4) The performance varies greatly with the BLOCKSIZE chosen in the NioFile.
I assume that this is going to be hardware/configuration and "type of
search" dependent, and as such is a configurable parameter.

Robert Engels

-----Original Message-----
From: Doug Cutting [mailto:cutting@apache.org]
Sent: Wednesday, May 25, 2005 4:20 PM
To: java-dev@lucene.apache.org
Subject: Re: major searching performance improvement


Robert Engels wrote:
> Attached are files that dramatically improve the searching performance
> (2x improvement on several hardware configurations!) in a multithreaded,
> high concurrency environment.

This looks like some good stuff!  Can you perhaps break it down into
independent, layered patches?  That way it would be easier to discuss
and integrate them.

> The change has 3 parts:
>
> 1) remove synchronization required in SegmentReader document. This
> required changes to FieldsReader to handle concurrent access.

This makes good sense.  Stylistically, I would prefer the cloning be
done in ThreadLocal.initialValue().  That way if another method ever
needs the input streams the cloning code need not be altered.

> 2) change FSDirectory to use a 'nio' to improve concurrency. Changed to
> use NioFile. This class has some workaround because under Windows, the
> FileChannel is not fully reentrant, and so allocates multiple handles
> per physical file - this code can be removed under non-Windows
> systems. This also required changes to InputStream to allow for reading
> at a direct offset.

Could you please explore making this a new Directory class, extending
rather than replacing FSDirectory?  That would make it easier for folks
to evaluate.  Look at MMapDirectory for an example.

Also, did you compare the performance of this to MMapDirectory?  That
already uses nio, and should thus avoid the thread contention of
FSDirectory.  However it does not scale well on 32-bit machines whose
address space limits indexes to 4GB.

Finally, for Windows-specific code, you can check
org.apache.lucene.util.Constants.WINDOWS at runtime.

> 3) move disk buffering into the Java layer to avoid the overhead of OS
> calls. The buffer percentage can be configured to store the entire index
> in memory. Running with as little as a 10% cache, the performance is
> dramatically improved. Reading larger blocks also improves the
> performance in most cases, but can actually degrade performance if doing
> very small reads. Using the cache implies that you have configured the
> JVM to have as much heap space available as the percent of index size on
> the disk. The NioFile can be easily changed to use a "soft" cache to
> avoid the potential of OutOfMemoryExceptions.

It would be nice if this functionality could be layered on any
Directory.  Did you consider making a CachingDirectory that one can wrap
around an existing Directory implementation, that keeps an LRU cache of
data?  Even 10% by default will probably break a lot of applications.
At the Internet Archive I frequently search indexes 100GB gigabyte
indexes on machines with just 1GB of RAM.  So I am leery of enabling
this by default.

Cheers,

Doug

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org

Mime
View raw message