Opened 19 months ago
Closed 19 months ago
#1488134 closed Bugs (fixed)
_listMailboxes in rcube_imap_generic.php is too slow.
| Reported by: | Mythics | Owned by: | |
|---|---|---|---|
| Priority: | 3 | Milestone: | 0.7-beta |
| Component: | IMAP connection | Version: | 0.5.4 |
| Severity: | major | Keywords: | imap folders list slow speed listmailboxes _listmailboxes bottleneck performance |
| Cc: |
Description
Hello,
Due to an improper directory structure on my end, an issue arose with our latest update where users are unable to go into folder management within RC.
The reason for this issue is due to hundreds of folders/files showing up as mail related, when they are in fact not.
As this issue was always due to one specific 'root' directory, we could exclude it from being dug through by manually editing roundcube.
We can still do this, but the speed at which the _listMailboxes function runs is significantly reduced since our last version of RC (I believe it was still .4).
The IMAP command runs instantly and the results are returned nearly instantly as well, but the parsing process of the function seems to be causing these issues (potentially tokenizeResponse, but I'm unsure).
As I can not immediately restructure every user's home directory, is this something I could easily fix myself with proper direction? My php knowledge is still quite limited, but I was able to easily track down this as the bottleneck for our situation.
Is this something we can expect to be fixed in a new release in the near future?
Thanks in advance.
PS: I labeled this as a bug only because I couldn't imagine this kind of speed reduction being intentional.
Change History (4)
comment:1 follow-up: ↓ 2 Changed 19 months ago by alec
- Milestone changed from later to 0.7-beta
comment:2 in reply to: ↑ 1 Changed 19 months ago by Mythics
Replying to alec:
Are you sure the bottleneck is inside the _listMailboxes()? I've found that sorting of folders is slow, but it's out side of _listMailboxes(). Please, check with svn-trunk version.
I'm currently using the most up-to-date freebsd port, which is 0.5.4 I believe.
I'm pretty sure that is is inside _listMailboxes(), as I've edited it to exclude the tremendous number of 'folders' that it tries to pull into RC. When it pulls in the results from the LIST or LSUB commands, I am only allowing it to add to $folders[] when it is a true folder.
There's a single folder in the root of the home directories of all our users, in some cases there are thousands of folders/files within this single 'root' folder.
Using the code below, it excludes what I'm needing it to right as it pulls the data in. So, while I could still be easily mistaken, I believe the issue is still within _listMailboxes.
The code for me right now looks like this:
if (!$lstatus || $cmd == 'LIST' || $cmd == 'LSUB') {
list($opts, $delim, $mailbox) = $this->tokenizeResponse($response, 3);
if (!preg_match('/www/', $mailbox)) {
// Add to result array
if (!$lstatus) {
$folders[] = $mailbox;
}
else {
$folders[$mailbox] = array();
}
// Add to options array
if (!empty($opts)) {
if (empty($this->data['LIST'][$mailbox]))
$this->data['LIST'][$mailbox] = $opts;
else
$this->data['LIST'][$mailbox] = array_unique(array_merge(
$this->data['LIST'][$mailbox], $opts));
}
}
}
comment:3 Changed 19 months ago by alec
Ok. I see in my tests that tokenizeResponse is indeed slower when dealing with very long strings.
comment:4 Changed 19 months ago by alec
- Resolution set to fixed
- Status changed from new to closed
I hope [9230525d] fixes the issue.

Are you sure the bottleneck is inside the _listMailboxes()? I've found that sorting of folders is slow, but it's out side of _listMailboxes(). Please, check with svn-trunk version.