<<< Date Index >>>     <<< Thread Index >>>

Re: Mark messages in mailbox as read without massive performance hit?!



On Wed, Dec 28, 2005 at 07:58:19PM -0600, Matthew D. Fuller wrote:
> On Wed, Dec 28, 2005 at 07:59:26PM -0500 I heard the voice of
> Derek Martin, and lo! it spake thus:
> > On Wed, Dec 28, 2005 at 04:39:22PM -0800, Arias Hung wrote:
> > > in order to mark all messages in a particular mailbox as read,
> > > however also using Maildir format results in a rather horrific
> > > performance hit should the mailbox contain more than even fifty or
> > > so messages.
> > 
> > If you want this to be faster, switch to mbox.
> 
> That doesn't make any sense.  

It definitely does, if you understand filesystem mechanics.

> Setting message flags in a maildir is
> just a rename(); 

rename() is more expensive than you think.  It only SEEMS quick
because you only do it once, usually.

> doing it in a mbox requires rewriting the whole mbox
> from the Status: line of the first message you're changing.  It's a
> lot *CHEAPER* in a maildir than in a mbox, unless your filesystem is
> totally nuts.  

To do it ONCE is cheaper in maildir.  To do it a whole bunch of times
ends up being extremely expensive, because the overhead to open a file
is very high.  Every message you rename means you open the directory
again.  For mail folders with very large numbers of messages on
anything resembling traditional Unix filesystems, mbox will win.
Guaranteed.

> Updating status flags is a big reason I switched to maildir years
> ago for active mailboxes; it takes fractions of a second to mark a
> few hundred mails read, instead of many seconds writing out new
> data.

If your hardware is slow, you will notice a difference with smaller
numbers of messages.  If your hardware is fast, it will take a while
before mbox starts to beat maildir.  But eventually it will, and with
each additional message, it will win by a lot more.

Don't believe me?  Create identical mailboxes with 50,000 messages in
them.  Change the status of each message.  See what happens.


-- 
Derek D. Martin    http://www.pizzashack.org/   GPG Key ID: 0xDFBEAD02
-=-=-=-=-
This message is posted from an invalid address.  Replying to it will result in
undeliverable mail.  Sorry for the inconvenience.  Thank the spammers.

Attachment: pgp4F98yH5S5P.pgp
Description: PGP signature