Subject: How do I determine number of unseen and deleted message guickly

From: [email-masked] (Mark Keasling)
Date: Tue, 31 May 94 21:04:04 JST

Mark,

I am trying to correct our dismal performance with the IMAP driver when
a remote mailbox contains deleted or unseen messages.  Basically,
I want to be able to get the number of unseen and deleted messages and
am not particularly interested in which ones are unseen or deleted.  These
values are used in mailbox status information and are checked very frequently.

Moving the cursor from one item to the next generates two calls to mail_search,
one to determine the number of unseen messages and another to determine
the number of undeleted messages.  When the mailbox is remote and as
long as deleted and unseen are zero, return is almost immediate; but, if
new mail arrives or messages are deleted the performance drops markedly
about to 7-8 seconds from initiation to completion.  A significant part of
that time seems to be spent in the c-client waiting for the server to respond.
What I would like to know is, is there a fast way to accurately obtain the
mailbox's deleted and unseen counts without having to use mail_search?

Mark K.

---

From: Mark Crispin <[email-masked]>
Date: Tue, 31 May 1994 19:01:09 -0700 (PDT)

> values are used in mailbox status information and are checked very frequently.

Once you have done a mail_search() to get the initial count of deleted 
and unseen messages, you can keep track of the changes in message status
caused by your application.  This doesn't help you with shared formats 
such as tenex and MTX which allow multiple simultaneous flag updates, but 
perhaps you can do the mail_search() update on a slower clock to fix up 
any cache inaccuracies.

What is of greater concern is why the mail_search() is taking so long.  
Normally, I would suspect search pre-fetching of envelopes (this can be 
disabled in modern versions of c-client via a mail_parameters() call) but 
this isn't an issue with your application.  I'd suggest turning on IMAP 
telemetry (via the OP_DEBUG flag in the mail_open() call) and logging it 
(from mm_dlog()) into a file.  Then look to see if there is anything 
egregiously wrong in the telemetry.  Pre-fetching would show up as a 
FETCH of envelopes after a SEARCH, but as I said I doubt it's happening 
unless you're doing something like mail_gc() in a misguided notion to 
save memory.

More likely there is some performance problem with your server.  Since 
you have a large mailbox and are using a server with only 8MB memory, try 
using the tenex format for mail and see if that improves performance.  I 
suspect that your server is swapping itself to death; an 8MB system is 
not a reasonable configuration in this day and age.