mime_something_to_entity() being very slow - request to apply a fix
Jacek Raczkiewicz <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <CABsGpit_eESg4C0je98x3hyb8PuuA4Seuqrti=QFH_ApmqnH9g@mail.gmail.com> |
Hello, I'm optimizing an application that is using gwlib a lot. I discovered that the mime_something_to_entity() function is very slow. Finally with a help of callgrind was able to figure out why. on line 409 in gwlib/mime.c octstr_dump() is called and that takes very long time to proceed for any binary files. I have tested with 71KB image and ended up with about 133 000 calls to sprintf() coming out from this function. Moreover this function does output to log file ONLY in debug mode, but all the calculations pare performed always and slowing down the function call always. If debug mode is OFF the string is formatted and just not saved to log file/dumped. I have for now commented out octstr_dump() call and my application works more than two times faster now (this simple function was using up 66% of execution time for given image size), when using bigger image the application does not slow down (it was slowing down a lot when octstr_dump() was there). I would like you to fix this function and include the patch into source code. I think you can just remove that octstr_dump() call from this function, or maybe rewrite octstr_dump() function to do all calculation only in debug mode (when it is actually saving to the log file), I think this seems like a best approah here. I do attach the callgrind chart showing the problem for 71kb image (the percentage next to function call shows total execution time, octstr_dump_real() shows 66%), I'm sure it gets worse when image size increase. Thanks in advance Jaek Raczkiewicz
execution.png
(image/png, 71.4 KB) - not displayed