Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#1485172 closed Feature Patches (fixed)

Patch to use imap_root before imap connect (significant speedup)

Reported by: ziba Owned by: alec
Priority: 5 Milestone: 0.2-stable
Component: IMAP connection Version: git-master
Severity: major Keywords:
Cc:

Description

By communicating the roundcube imap_root preference to iloha imap before connecting to imap, we can take advantage of iloha's ability to skip the namespace discovery phase.

In an environment like ours (80K users, 900K mailboxes), this cuts the time it takes the backend to load a single email message from ~1.7 seconds to ~0.2 seconds (on an unloaded test system).

Please let me know if I can change anything to make this patch more acceptable. Thanks.

Attachments (4)

use_imap_root_before_connect.patch (732 bytes) - added by ziba 5 years ago.
use_imap_root_before_connect_v2.patch (748 bytes) - added by maharaja 5 years ago.
updated patch
use_imap_root_before_connect_v3.patch (1.0 KB) - added by ziba 5 years ago.
v2 is missing a semicolon
use_imap_root_before_connect_v4.patch (2.5 KB) - added by ziba 4 years ago.
now with delimiter option and is_string checking

Download all attachments as: .zip

Change History (15)

Changed 5 years ago by ziba

comment:1 Changed 5 years ago by maharaja

two things

# if rcmail::get_instance()->config->get('imap_root') gives an empty string, the patch renders roundcube unusable.
# normally i am against the usage of globals in such a way. but this is better than nothing :)

Changed 5 years ago by maharaja

updated patch

Changed 5 years ago by ziba

v2 is missing a semicolon

comment:2 Changed 4 years ago by alec

  • Milestone changed from later to 0.2-stable
  • Owner set to alec

comment:3 Changed 4 years ago by alec

Two cons: this will not work with empty (NIL) imap_root, also setting this will cause that delimiter will be not read

comment:4 Changed 4 years ago by ziba

Thanks for looking into this. I've restated the problems to make sure that I understand them and offered some fixes. Let me know what you think and I can remake the patch.

problem:

Setting myprefs["rootdir"] to save the time spent determining rootdir prevents conn->delimiter from being populated. However, determining the delimiter is done with the exact same potentially time consuming process.

possible fix:

Add myprefs["delimiter"] preference to iloha mail which is set from a new roundcube preference: imap_delimiter. Require imap_root and imap_delimiter to be set together if set at all

problem:

patch does not work with empty string as rootdir

possible fix:

Explicitly check for and allow empty string

in rcube_imap.php: if ($imap_root || $imap_root === "") {

in imap.php: if ($my_prefs["rootdir"] || $my_prefs["rootdir"] === "") {

comment:5 Changed 4 years ago by alec

Sounds OK, with one note. Will be better to check imap_root with is_string(), then in config we can just set those options to FALSE or NULL. Also I've found that setting imap_delimiter will give as another performance upswing (one unnecessary LIST command will be ommited). Make a patch. I'm also curious how imap_delimiter option will improve performance on heavy load. Give some numbers here, please.

Changed 4 years ago by ziba

now with delimiter option and is_string checking

comment:6 Changed 4 years ago by ziba

I've made the discussed patch changes and added config/main.inc.php.dist values (you might want different defaults). Let me know if I can make any more changes. We're already using the earlier version of this patch in production, so I can't turn it off and give you numbers for the impact on a loaded system. On an unloaded machine, the benefit for us (a bit of a weird case) is ~1.5 seconds every imap connect.

Thanks.

comment:7 Changed 4 years ago by alec

With your previous patch delimiter was set using LIST command, when imap_delimiter was added in your patch last version, LIST command is not executed. I was talking about that effect. Is that change noticeable?

comment:8 Changed 4 years ago by alec

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

Applied with some changes in [030c848b].

comment:9 Changed 4 years ago by maharaja

minor correction to UPGRADING, line 21:

WARNING: If you don't know what an "IMAP root directory" is, set the imap_root option to NULL.

comment:10 Changed 4 years ago by ziba

Sorry. I misunderstood your question about imap delimiter fetch time. It's not in production yet, but on an unloaded system it takes less than 0.001 seconds to fetch the delimiter from the imapproxy that runs on the webserver. I would expect similar results in production.

comment:11 Changed 4 years ago by alec

... and [2b5c123a] (lost commit in rcube_imap.inc).

Note: See TracTickets for help on using tickets.