Opened 5 years ago

Closed 5 years ago

#1485105 closed Bugs (wontfix)

Bypass costly PHP message sorting if IMAP server support SORT

Reported by: jeblair Owned by:
Priority: 5 Milestone: 0.2-alpha
Component: PHP backend Version: 0.1.1
Severity: normal Keywords: imap sort
Cc:

Description

If an IMAP server supports SORT, RoundCube still sorts the message headers in rcube_imap (using the sorter class) nonetheless. This operation can be expensive on large mailboxes. Instead, it should take advantage of the fact that the UIDs it gets from the IMAP server are already sorted. The only part of the code wrapped by if(!$headers_sorted) that needs to be run on output from an IMAP server that supports SORT is potentially reversing the array at the end.

I'm attaching a patch that separates the functionality of sorting and reversing, so that the headers are sorted or reversed only when needed.

Attachments (1)

sort.diff (1009 bytes) - added by jeblair 5 years ago.
Patch to rcube_imap to sort only when necessary

Download all attachments as: .zip

Change History (4)

Changed 5 years ago by jeblair

Patch to rcube_imap to sort only when necessary

comment:1 Changed 5 years ago by francesco_r

I think the big problem of slow speed regarding Roundcube is that sort ALL the messages. For example i use Courier-Imap: very stable but also very slow... so when i do a server-side sorting it takes 40-50 seconds to open a mailbox with 10000 messages. In the same server Squirrelmail open the inbox in 1 second. Because it sort only the first 40 messages and not the entire inbox. So i think would be nice to sort only the messages present in the actual list.

comment:2 Changed 5 years ago by alec

  • Milestone changed from later to 0.2-alpha

comment:3 Changed 5 years ago by thomasb

  • Resolution set to wontfix
  • Status changed from new to closed

This is not correct. The fetch header command does not necessarily return the headers in the same order as the UIDs are requested. This can be considered as a bug of some IMAP servers but it's the reality. For this reason, the message headers need to be sorted "manually".

However, only the current message set (one page) needs to be sorted. In [05d180a8] I tried to improve the sorting algorithm by omitting array_search which obviously had to iterate the complete message index.

Note: See TracTickets for help on using tickets.