Subject: mail_uid_sequence: a performance hog

From: "Rubinstein, Dmitry" <[email-masked]>
Date: Mon, 23 Aug 1999 21:11:55 +0300

Hi, all!

There is a code in mail_uid_sequence() (mail.c), that deals with the '*' in
uid sequences. Basically it calls mail_uid() in order to discover what uid
stands for '*', and then passes on to the generic code (get the
corresponding sequence IDs, make a loop to set the Sequence flag for
appropriate messages). 

An alternative approach would be to consider '*' a special case that demands
no calls to mailbox driver at all. That is, if we have a sequence '5:*', we
find the sequence ID of '5', and then make a loop from '5' to stream->nmsgs.

The current approach is somewhat unefficient. The effect is probably minimal
when considering mailbox drivers that are based on file system, becomes
evident when considering mailbox driver that work over the net (like IMAP
driver), and becomes unbearable when you try to make certain optimizations
while serving as middleware between a real server and a client. Wouldn't it
be better to make a special treatment of '*'?

TIA,

--
Dmitry Rubinstein 
-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------

---

From: Mark Crispin <[email-masked]>
Date: Mon, 23 Aug 1999 11:59:38 -0700 (PDT)

I don't understand your comment about the IMAP driver.  If you're using IMAP,
then mail_uid_sequence() is generally never called.  If you give it a UID
sequence, that sequence as text is passed to the IMAP server.

I don't see any situation in which you can have the purported "unbearable"
problem in unmodified c-client code.  Even in the one case (overviews, which
aren't part of IMAP) where the IMAP driver can call mail_uid_sequence(), the
worst that'll have is a fetch of the UID for the message with sequence
matching stream->nsgs.  Once the UID is fetched for that message, it's cached
and isn't fetched again.

If you're modifying the code to do IMAP UID sequence parsing locally, then you
can just as easily also make the type of modification that you suggest to
accomodate your other modification.

In general, I don't want to get into the business of changing c-client to make
someone's modification more efficient, especially if the result is larger and
more obtuse code.  If it makes no difference in unmodified c-client, then
there isn't any benefit to putting it in into unmodified c-client.

In any case, a better programming technique is to use sequence numbers
whenever possible.  UIDs are never the preferred way to get at messages if you
have the sequence number available.  Applications which try to think that "all
the world is UID" will never be able to use c-client (or IMAP) as effectively
as those which use both UIDs and sequence numbers, choosing the one that is
appropriate for the task at hand.