Summary | Improve String::wordwrap() performance |
Queue | Horde Framework Packages |
Queue Version | FRAMEWORK_3 |
Type | Enhancement |
State | Resolved |
Priority | 1. Low |
Owners | |
Requester | ryu (at) ryux (dot) org |
Created | 10/07/2009 (5740 days ago) |
Due | |
Updated | 09/29/2011 (5018 days ago) |
Assigned | |
Resolved | 09/29/2011 (5018 days ago) |
Milestone | |
Patch | No |
State ⇒ Resolved
ticket #9405.Prefer mb_substr() over iconv_substr() because it's several magnitudes
faster (Evert Pot,
Request #8627).2 files changed, 12 insertions(+), 12 deletions(-)
http://git.horde.org/horde-git/-/commit/839b9907b6ccadc4935eaf9b88a1d4c609074863
run through wordwrap anymore after commit
d90a36975cb9417554c78d991b170f795ac21712.
incredibly slow compared to mb_substr, and it gets called *a lot*.
Here's a benchmark script:
http://pastebin.com/r63kUt22
On my mac, the difference is very much visible, but not terrible performance:
iconv_substr: 0.014400005340576
mb_substr: 0.00049901008605957
substr: 3.7193298339844E-5
On 2 linux machines we tried, the numbers looked more like this:
iconv_substr: 8.3735179901123
mb_substr: 0.00039505958557129
substr: 4.8160552978516E-5
Yes that's 8 seconds for iconv_substr, 0.0004 seconds for mbstring
and 0.00005 for the non-unicode aware function.
So my fix is to change Horde_String::substr and prefer mbstring over iconv
Do you have a list of rules and others considerations ? Maybe a RFC ?
http://tools.ietf.org/html/rfc2445
http://tools.ietf.org/html/rfc2426
http://www.imc.org/pdi/vcal-10.txt
http://www.imc.org/pdi/vcard-21.txt
Request #6658might help too.Do you have a list of rules and others considerations ? Maybe a RFC ?
Is exists unit tests for this method ?
And for the size message problem ? What is the solution ?
Thanks
Version ⇒ FRAMEWORK_3
State ⇒ Accepted
Priority ⇒ 1. Low
still wouldn't fit into a single SyncML message.
String::wordwrap() being slow is a known issue though. This is
happening because of the special line folding rules and charset
considerations that are required when wordwrapping vCard/iCalendar
data. Some small improvements have already been in CVS, but this
method probably has to be re-written from scratch.
Patch ⇒ No
State ⇒ Unconfirmed
Milestone ⇒
Queue ⇒ Turba
Summary ⇒ Turba export doesn't work with (big) image
Type ⇒ Bug
Priority ⇒ 2. Medium
Ko for example) and it finish by :
Oct 07 08:51:18 HORDE [debug] [horde] Sending replace from server:
20091007082330.381433t87qr4a12a@mail.example.com [pid 18652 on line
577 of "/data/internet/mail.example.com/_www.1.2.4/lib/SyncML/Sync.php"]
Oct 07 08:51:18 HORDE [debug] [horde] Maximum message size 20000
approached during replace; current size: 497 [pid 18652 on line 586 of
"/data/internet/mail.example.com/_www.1.2.4/lib/SyncML/Sync.php"]
Oct 07 08:51:18 HORDE [warning] [horde] Data item won't fit into a
single message. Partial sending not implemented yet. Item will not be
sent! [pid 18652 on line 590 of
"/data/internet/mail.example.com/_www.1.2.4/lib/SyncML/Sync.php"]
When we look a bit more, we find that the method String::wordwrap is
very long (> 15 minutes for me) to explode photo, causing a timeout to
sync process with a mobile... This function is called in
iCalendar::_exportvData()
To sum up how to reproduce :
- add a photo with important size (130 ko)
- sync mobile
result : 2 ways
1. timeout (after 10 min) and stop (with slow sync on next sync) (with Edge)
2. no timeout (15 min) but problem on transfer (with WiFi)
I m ready to create a fix this bug, but I need help on what to do...
Thanks