[PATCH] IMAP: improve quickchanged() performance
Sebastian at SSpaeth.de
Mon Apr 11 17:33:11 BST 2011
For each folder we were making a second IMAP request asking for the
latest UID and compared that with the highest UID in our
statusfolder. This catched the case that 1 mail has been deleted by
someone else and another one has arrived since we checked, so that the
total number of mails appears to not have changed.
I wonder if we want to capture this case in the quickchanged() case and
am throwing this patch in for discussion by removing the check. It
improves my performance from 8 to about 7.5 seconds per check (with lots
of variation) and we would benefit even more in the IMAP<->IMAP case as
we do one additional IMAP lookup per folder on each side then.
The downside is that we don't catch mails in the above scenario (someone
deleted a mail remotely and a new one arrived)
What do you think?
The patch is on top of the 2 patch-series that I just sent, but with
some fuzzy offset should apply to master as well.
P.S. Nicolas no need to review this commit message it wouldn't be
the final one ;-)
Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
offlineimap/folder/IMAP.py | 18 ------------------
1 files changed, 0 insertions(+), 18 deletions(-)
diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py
index 49362c8..abf6464 100644
@@ -97,26 +97,8 @@ class IMAPFolder(BaseFolder):
if maxmsgid != statusfolder.getmessagecount():
- if maxmsgid < 1:
- # No messages; return
- return False
- # Now, get the UID for the last message.
- response = imapobj.fetch('%d' % maxmsgid, '(UID)')
- # Discard the message number.
- messagestr = response.split(' ', 1)
- options = imaputil.flags2hash(messagestr)
- if not options.has_key('UID'):
- return True
- uid = long(options['UID'])
- saveduids = statusfolder.getmessageuidlist()
- if uid != saveduids[-1]:
- return True
# TODO: Make this so that it can define a date that would be the oldest messages etc.
More information about the OfflineIMAP-project