Summary | Large mailboxes takes many seconds to load and causes CPU at 100% |
Queue | Horde Framework Packages |
Type | Enhancement |
State | Resolved |
Priority | 1. Low |
Owners | slusarz (at) horde (dot) org |
Requester | cunha17 (at) gmail (dot) com |
Created | 08/03/2015 (3678 days ago) |
Due | |
Updated | 08/05/2015 (3676 days ago) |
Assigned | 08/05/2015 (3676 days ago) |
Resolved | 08/05/2015 (3676 days ago) |
Milestone | |
Patch | No |
Assigned to Michael Slusarz
State ⇒ Resolved
array_replace requires at least one array.
Additionally, there's significant overhead involved with
call_user_func_array() and array_replace(). Better just to use the
array union operator - benchmarked at 25% faster on a 500,000 message
thread object, with the same maximum memory usage.
commit 7d4019642f279fc5471bd330e9654a976154a280
Author: Michael M Slusarz <slusarz@horde.org>
Date: Wed Aug 5 01:12:01 2015 -0600
[mms] Improved performance of Horde_Imap_Client_Data_Thread
object when containing large number of messages (
Request #14075)..../lib/Horde/Imap/Client/Data/Thread.php | 7 +-
framework/Imap_Client/package.xml | 8 ++-
.../test/Horde/Imap/Client/Data/ThreadTest.php | 66
++++++++++++++++++++
3 files changed, 75 insertions(+), 6 deletions(-)
http://github.com/horde/horde/commit/7d4019642f279fc5471bd330e9654a976154a280
Type ⇒ Enhancement
Priority ⇒ 1. Low
State ⇒ Assigned
Priority ⇒ 3. High
State ⇒ Unconfirmed
Patch ⇒ Yes
Milestone ⇒
Queue ⇒ Horde Framework Packages
Summary ⇒ Large mailboxes takes many seconds to load and causes CPU at 100%
Type ⇒ Bug
The class where the performance problem reside is
Horde_Imap_Client_Data_Thread.
And the method causing the high CPU usage is _getAllIndices().
This method uses a simple iteration through _thead array (in my case
having 8088 elements) and merges the keys of each sub-array with the
previous one. So it calls array_merge and array_keys 8088 times:
protected function _getAllIndices()
{
$out = array();
reset($this->_thread);
while (list(,$v) = each($this->_thread)) {
$out = array_merge($out, array_keys($v));
}
return $out;
}
I replaced this iteration with this and the performance issue were gone:
protected function _getAllIndices()
{
return array_keys(call_user_func_array('array_replace',
$this->_thread));
}
Hope it helps and best regards,
Cristiano da Cunha Duarte