Skip to content
This repository has been archived by the owner on Nov 8, 2018. It is now read-only.

fetch UIDs and DATEs of all messages and do the pagination client side #1486

Merged
merged 2 commits into from
Jun 16, 2016

Conversation

ChristophWurst
Copy link
Contributor

@ChristophWurst ChristophWurst commented May 10, 2016

Inspired by @DeepDiver1975's PR #747 I debugged the message fetching code and found out none of the IMAP servers I use have SORT capabilities. This means horde will do the sort client-side. While that's alright, looking at horde_imap.log I observed that way too much information is queried for sorting. It appears the full envelope data is fetched for sorting by date, which is useless and performance heavy.

This PR is a experiment where the sorting is done client-side by fetching message UIDs and DATEs, slicing the result and fetching the full info of that slice only.

Benchmark

I compared fetching the unified inbox with three accounts (two on my hoster, one is gmail).

Current master: ~2050ms
This branch: ~1550ms

Considering that ~500ms are needed for an OC request without querying the a IMAP server (tested with PageController::index), the speedup on my setup is about 32%. It will differ on other systems, depending on the server configuration and the mailbox size.

If a server supports SORT, this strategy could be slower than what horde is doing, but I don't have any server available to test this with. It is slower, see comment below

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @DeepDiver1975, @thomasi and @zinks- to be potential reviewers

@ChristophWurst
Copy link
Contributor Author

@owncloud/mail let me know what you think. Would be cool if some of you do the comparison too to see how that strategy behaves on different systems ;-)

@ChristophWurst
Copy link
Contributor Author

Another benchmark: Created a folder and put 5000 messages into it on an IMAP server without SORT capability:
master: ~6350ms
this PR's branch: ~1650ms

@ChristophWurst
Copy link
Contributor Author

ChristophWurst commented May 10, 2016

Here's a simple script to create a bunch of messages https://github.com/ChristophWurst/horde-playground/blob/master/imap_spammer.php

@ChristophWurst
Copy link
Contributor Author

Another benchmark using the IMAP test docker that support SORT, also with 5000 test messages:
master: ~500ms 😮
this PR's branch: ~1400ms

@ChristophWurst
Copy link
Contributor Author

ChristophWurst commented May 10, 2016

SORT capability can be checked with

$supported = $client->capability->query('SORT');

We could use that to select the most qualified algorithm

@kklem0
Copy link
Contributor

kklem0 commented May 10, 2016

I noticed the same thing on my Gmail account awhile ago, +1 for this.
When the server supports SORT we should always use it directly IMO.

@ChristophWurst ChristophWurst modified the milestones: 0.4.5, 0.5, 0.5.1, 0.5.2 May 29, 2016
@ChristophWurst
Copy link
Contributor Author

@Gomez @jancborchardt this is ready for some testing!

@jancborchardt
Copy link
Contributor

👍 still works on my SORT servers. :)

@ChristophWurst ChristophWurst merged commit 9ab88c1 into master Jun 16, 2016
@ChristophWurst ChristophWurst deleted the alternative-fetch-strategy branch June 16, 2016 12:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants