Doug Cutting wrote:
If you do get a chance to look into this, I'd love to hear more.

FieldsReader.doc() could easily be re-written to be re-entrant. For a start, it could synchronize separately on fieldStream and indexStream, which would let two threads use it at once. (If an index is not optimized, the situtation would be even better, since there would be a fieldStream and indexStream per index segment.)

If that's not enough, then it could be re-written to use either a pool of cloned input streams, or just to clone a new stream for each call. (The primary expense of cloning a stream is allocating a 1k buffer.)

I think that using a pool of cloned inputStreams would be the best solution. I've implemented such a solution locally using two pools of 3 readers each (configurable via system properties) and will post the diff after I do some testing to confirm accuracy and speed improvements.

I'm a little unsure of how exactly to best write JUnit test(s) for these changes as any tests should take into account multiple threads and simultaneous reads (to test that the object pool I wrote actually works as advertised). Any ideas would be appreciated.


Regards,

Bruce Ritchie

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to