Hi,
walking through roundcube's code I've found some room for small improvements. if you sum them all together you may get some nice performance improvement (not very huge - but you can probably notice it)
what I'm talking of are mainly style questions... because there are functions in php that do the same as another function, with the small difference that function X is faster
for example print() is slower than echo() also double-quotes (") are up to 25% slower than concatenating strings with single quotes (') - which is a HUGE performance boost
I've found a site which lists some of those functions - check [1] I quickly compared the list with roundcube's codebase those are the main places where there is still room for improvement:
one small note about [1]: afaik switch/case is faster than if/else that site says the opposite
some of those things can be put into roundcube's codebase quite easily maybe you can create some "Junior Jobs" section in your wiki, so bored devs may write patches (which of course should be reviewed by an experienced dev)
however, feel free to discuss this oh, and I know: this whole mail is not mean for today's development... but more something for the future
Regards, Martin
[1] http://progtuts.info/55/php-optimization-tips/ _______________________________________________ List info: http://lists.roundcube.net/dev/
Are you are trying to say that with once loaded, compiled and cached code there would be a difference between single and double quotes?
And also you are saying that two functions which are both aliases to the same zend engine function there will be difference after compilation, especially when using Zend Accelerator or eAccelerator or XCache?
And, most notably, do you really mean that all this stuff would relly matter with complex code and lots of IMAP and MySQL interaction?
Premature optimization is the root of all evil. Do you have any benchmarks? Did you profile the code and actually saw that concatenating stings takes at least 10% of running imap_open?
В Thu, 2 Jul 2009 21:38:43 +0200 darklight darklight.xdarklight@googlemail.com пишет:
Hi,
walking through roundcube's code I've found some room for small improvements. if you sum them all together you may get some nice performance improvement (not very huge - but you can probably notice it)
what I'm talking of are mainly style questions... because there are functions in php that do the same as another function, with the small difference that function X is faster
for example print() is slower than echo() also double-quotes (") are up to 25% slower than concatenating strings with single quotes (') - which is a HUGE performance boost
I've found a site which lists some of those functions - check [1] I quickly compared the list with roundcube's codebase those are the main places where there is still room for improvement:
- use ' instead of " (where possible - for example 'this is a test' .
"\n" would still be faster than "this is a test\n" - but you cannot replace '"\n" by '\n')
- multiple parameters for echo - but most people prefer concatenating over this multiple argument feature (I have to admit: I also prefer string concatenation)
- pre-increment instead of post-increment (should be quite easy to do
this, since you need post-increment only in very few cases)
- unset() should be used more often (bigger task)
- use require() instead of require_once() - this is probably a bigger
task too
one small note about [1]: afaik switch/case is faster than if/else that site says the opposite
some of those things can be put into roundcube's codebase quite easily maybe you can create some "Junior Jobs" section in your wiki, so bored devs may write patches (which of course should be reviewed by an experienced dev)
however, feel free to discuss this oh, and I know: this whole mail is not mean for today's development... but more something for the future
Regards, Martin
[1] http://progtuts.info/55/php-optimization-tips/ _______________________________________________ List info: http://lists.roundcube.net/dev/
List info: http://lists.roundcube.net/dev/
Hi,
On Thu, Jul 2, 2009 at 10:12 PM, Алексей Михеевamiheev@st-host.ru wrote:
Are you are trying to say that with once loaded, compiled and cached code there would be a difference between single and double quotes?
well, there are performance improvments with double quotes the PHP parser checks for variables inside the string itself, which (of course) costs (much) time with single quotes the interpreter handles everything inside the single-quotes as plain text, it does not even check for special characters (like \n) in there
And also you are saying that two functions which are both aliases to the same zend engine function there will be difference after compilation, especially when using Zend Accelerator or eAccelerator or XCache?
I have no clue about caching engines so I can't say anything here - sorry
And, most notably, do you really mean that all this stuff would relly matter with complex code and lots of IMAP and MySQL interaction?
well, of course this would not speed up MySQL queries or IMAP performance, but it would improve performance (at least a tiny bit - but sum that together...) everywhere you are doing stuff with strings (which is probably a quite big part of the code :))
Premature optimization is the root of all evil. Do you have any benchmarks? Did you profile the code and actually saw that concatenating stings takes at least 10% of running imap_open?
no, I haven't checked any of those cases specially for roundcube, but every language (no matter if it's a scripting language or any other language) has always more ways to archieve a goal. in java for example you can use StringBuilder instead of concatenating strings - StringBuilder will be faster (at least in most cases)
PS: as I said in my first mail - no huge performance improvements can be done by just using faster PHP-functions. but why not save some milliseconds here - some more there - and some more right behind that tree? :) if you sum everything up the result should be pretty OK
one last note: when you're testing - make sure your PHP environment is clean and you are testing under good conditions benchmarking PHP scripts is probably a bad idea when you are using 100% CPU and 100% RAM with other applications at the same time
Regards, Martin _______________________________________________ List info: http://lists.roundcube.net/dev/
On Thu, 2 Jul 2009 21:38:43 +0200, darklight darklight.xdarklight@googlemail.com wrote:
walking through roundcube's code I've found some room for small improvements. if you sum them all together you may get some nice performance
improvement
(not very huge - but you can probably notice it)
The notion of micro optimizations in PHP has been a recent topic lately, with a page from Google getting a lot of recognition:
http://code.google.com/speed/articles/optimizing-php.html
I would suggest everyone at least read a response from Gwynne Raskind before seriously contemplating the idea of combing through the RoundCube source to apply these sort of micro optimizations, however:
http://groups.google.com/group/make-the-web-faster/browse_thread/thread/ddfb...
Andre _______________________________________________ List info: http://lists.roundcube.net/dev/
On Fri, Jul 3, 2009 at 5:55 AM, Andreandre@neo-anime.org wrote:
On Thu, 2 Jul 2009 21:38:43 +0200, darklight darklight.xdarklight@googlemail.com wrote:
walking through roundcube's code I've found some room for small improvements. if you sum them all together you may get some nice performance
improvement
(not very huge - but you can probably notice it)
The notion of micro optimizations in PHP has been a recent topic lately, with a page from Google getting a lot of recognition:
http://code.google.com/speed/articles/optimizing-php.html
I would suggest everyone at least read a response from Gwynne Raskind before seriously contemplating the idea of combing through the RoundCube source to apply these sort of micro optimizations, however:
http://groups.google.com/group/make-the-web-faster/browse_thread/thread/ddfb...
That's a great response. And that was one hilarious video. ;-) Usually, you would think that Google knows what they are doing, but it seems like that is not always the case.
@Martin
If you are concerned about the speed, feel free to get Xdebug and enable the profiler. It'll provide you with Cachegrind files which you can view in WinCacheGrind (windows), KCacheGrind (linux/kde) or webCacheCrind (browser).
Those files help you figure out bottle-necks in PHP code and if you can solve any of them or want feedback on your discoveries, always feel free to ping the list. Of course we're not holding back on optimization, but we'd like to avoid the unnecessary.
Till _______________________________________________ List info: http://lists.roundcube.net/dev/
Hi,
interesting to read... everything I've read before basically said what that google article said but good that some PHP devs cleared things up
@Martin
If you are concerned about the speed, feel free to get Xdebug and enable the profiler. It'll provide you with Cachegrind files which you can view in WinCacheGrind (windows), KCacheGrind (linux/kde) or webCacheCrind (browser).
I already have this running :)
Those files help you figure out bottle-necks in PHP code and if you can solve any of them or want feedback on your discoveries, always feel free to ping the list. Of course we're not holding back on optimization, but we'd like to avoid the unnecessary.
I already found one place where there was room for optimization ALEC already fixed it - and the performance boost was huge :)
Regards, Martin _______________________________________________ List info: http://lists.roundcube.net/dev/
On Mon, Jul 6, 2009 at 7:58 PM, Martindarklight.xdarklight@googlemail.com wrote:
Hi,
interesting to read... everything I've read before basically said what that google article said but good that some PHP devs cleared things up
@Martin
If you are concerned about the speed, feel free to get Xdebug and enable the profiler. It'll provide you with Cachegrind files which you can view in WinCacheGrind (windows), KCacheGrind (linux/kde) or webCacheCrind (browser).
I already have this running :)
Those files help you figure out bottle-necks in PHP code and if you can solve any of them or want feedback on your discoveries, always feel free to ping the list. Of course we're not holding back on optimization, but we'd like to avoid the unnecessary.
I already found one place where there was room for optimization ALEC already fixed it - and the performance boost was huge :)
Regards, Martin
That's great! Thanks for contributing! :) Keep it coming.
Till _______________________________________________ List info: http://lists.roundcube.net/dev/