[dev] Horde imap client performance

Michael M Slusarz slusarz at horde.org
Thu Jul 14 18:17:22 UTC 2011


Quoting Ruu Gulin <ruu.gulin at gmail.com>:

> Thank you for the help!
>
>
>> This sounds like an issue with your network connection then, or at
>> least with PHP's socket connection.  If it is working fine when
>> network latency is eliminated, then it would not seem to be an issue
>> with the Horde Imap code per se.
>>
>> And it shouldn't be an issue with pipelining commands, since we
>> optimize the search and send it out in a single command.  And the PHP
>> imap functions will generally send a bunch of additional commands
>> which make it even less efficient.
>
> That's what i thought, so I didn't expect this problem. Both  
> request, horde imap
> and php imap (imap_fetchheader()) return just a single email. Maybe it's the
> internet connection, but I tried it from a server on my local  
> computer as well
> as from an external webserver. Anyway, i will try follow your  
> suggestion to log
> the imap traffic.

imap_fetchheader() != Horde_Imap_Client envelope return.  Those are  
two completely different items.   imap_fetchheader() does nothing more  
than return the raw text of the header of the message - this requires  
no parsing whatsoever.  Envelope data requires parsing of this header,  
both on the server side (to generate the envelope response) and on the  
client side (to parse the server's response).  So this is comparing  
apples and oranges.

Additionally, are you sure you are not unnecessarily grabbing ALL  
messages from the mailbox using the Horde_Imap_Client call?  Your  
example code had:

$query = new Horde_Imap_Client_Fetch_Query();
$query->envelope();
$imap->fetch('INBOX', $query);

But this will grab the envelope data from all messages in the mailbox.  
  If you really only want data from a single message, you want instead:

$imap->fetch('INBOX', $query, array('ids' => new  
Horde_Imap_Client_Ids($msg_id)));

>> First, it wouldn't be done in Socket.php - it would be done in the
>> Envelope data object.
>> Second, one issue is that some IMAP servers will return the envelope
>> data already decoded into UTF-8 (it is not entirely clear whether this
>> is proper according to the RFC).  Thus, we can't guarantee the return
>> value.
>> Third, there has to be a way to get the raw return value.
>>
>> A solution would be to add additional properties to the envelope
>> object that will contain values guaranteed to be decoded (e.g.
>> subject_decoded, from_decoded).
>
> ok, i understand. thanks again, I was just surprised that the output of the
> structure (Horde_Imap_Client_Data_Fetch::getStructure()) was in utf8 but the
> envelope wasn't.

The structure query is returning Horde_Mime_Part objects, which are  
complex objects (the raw structure string returned from the IMAP  
server is pretty much worthless by itself).  Conversely, the envelope  
queries are returning small strings (or small e-mail data objects)  
that are usable as-is.  So the need for full parsing at query-time is  
less obvious.  But as mentioned, it probably does make sense to add  
decoding "shortcuts" to the Envelope object to save on  
Horde_Mime::decode() calls, although the latter doesn't add that much  
overhead.

michael

___________________________________
Michael Slusarz [slusarz at horde.org]



More information about the dev mailing list