performance problems with notmuch new

Olly Betts olly at survex.com
Wed Apr 22 16:21:30 PDT 2020


On Mon, Apr 20, 2020 at 11:36:36AM -0300, David Bremner wrote:
> Franz Fellner <alpine.art.de at gmail.com> writes:
> 
> > I also suffer from bad performance of notmuch new.  I used notmuch
> > some years ago and notmuch new always felt instantanious.  Had to stop
> > using it because internet was too slow to sync my mails :/ Now (with
> > better internet and a completely new setup using mbsync) indexing one
> > mail takes at least 10 seconds, sometimes even more.  It can go into
> > minutes when I get lots of mail (~30...).

First question: what version of Xapian are you using?

And second thing to check, are you committing each message separately?

The commit operation tries to ensure that the data has actually been
written out to disk, so the time to index one message by itself isn't
indicative as it'll often mostly just be waiting for fdatasync() or
similar to return.

If you index 30 messages but commit each separately (i.e. run "notmuch
new" 30 times picking up one new message each time) that'll probably
scale something like linearly, but indexing a batch of 30 messages
should be much quicker per message.

> > When I run it after a
> > reboot I can have breakfast while notmuch starts up...  This is all on
> > spinning rust. I thought of getting an SSD but not in the near future.

After reboot the disk cache won't have any of the database in, so the
first operation will typically be slower, especially with a spinning
drive where seeks are relatively slow.

> > What I observe during that time: notmuch doesn't really need much CPU.
> > iotop shows constant read and write with extremely low rates, under
> > 1MB/sec.  So I think it might be an issue in xapian?
> 
> Just in case one of the xapian experts can suggest some kind of test for
> why you might be seeing this behaviour, I've included the xapian list in
> CC.

It sounds like you're seek-limited in this "cold cache" phase.  That is
not necessarily related to the slow indexing, but it could be.

I'd check the SMART diagnostics for the drive first (e.g. with
smartctl).  It's not the most likely cause, but it's quick to check and
if the drive is starting to fail it's better to find out sooner rather
than later.

Then I'd try compacting the database (I think there's a "notmuch
compact" subcommand to do this).
 
If that doesn't help, profiling the I/O would probably be my next
suggestion - there are some tools in the xapian git repo to help with
this (in xapian-maintainer-tools/profiling).  Under Linux I'd suggest
the strace ones (there's also an LD_PRELOAD library but it may need
tweaking for 32 vs 64 bit).

Cheers,
    Olly


More information about the notmuch mailing list