[Xapian-devel] About memory index/search in multithread program

Olly Betts olly at survex.com
Thu Jun 26 07:33:46 BST 2014


On Thu, Jun 26, 2014 at 01:19:20PM +0800, Yanxiong Lu wrote:
> There may be some solutions,for example
> class XAPIAN
> {
>     *static* int InitDatabase();  //for reading only, do not need lock, but
> if writing use lock
>     int Search(); //safe in one object, do not need lock
> };
> XIPIAN xp[ THREAD_NUM ];
> 
> one thread use one object, they use one database.
> these can be in memory with one database.

As I already tried to explain, if you're concerned about performance,
the current inmemory backend isn't the answer you are looking for.
Eliminating the need for the user to lock around searches isn't going to
magically solve that.

I don't really see how your 6 line sketch above helps either.  Xapian
makes *NO* thread-safety guarantees - even in the "reading only" case
you should be locking.  Even if it happens to work currently, there's
no guarantee it'll work in the next release.

Cheers,
    Olly



More information about the Xapian-devel mailing list