darklight | 2 Jul 21:38 2009

[RCD] php code design/performance

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
(Continue reading)

Face
Picon

Re: [RCD] php code design/performance

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 <at> 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
(Continue reading)

darklight | 2 Jul 23:11 2009

Re: [RCD] php code design/performance

Hi,

On Thu, Jul 2, 2009 at 10:12 PM, Алексей Михеев<amiheev <at> 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
(Continue reading)

Andre | 3 Jul 05:55 2009

Re: [RCD] php code design/performance


On Thu, 2 Jul 2009 21:38:43 +0200, darklight
<darklight.xdarklight <at> 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/ddfbe82dd80408cc

Andre
_______________________________________________
List info: http://lists.roundcube.net/dev/

Patrick Nagel | 3 Jul 05:59 2009
Picon

[RCD] Incompatibility with PHP 5.2.10?


Hi Roundcube devs,

I updated four virtual servers to PHP 5.2.10 (from 5.2.9) yesterday, and since
then the Roundcube instances on all of them are non-functional. Just a blank
page, and the following error message in apache's error_log:

[Fri Jul 03 03:42:50 2009] [error] [client 1.2.3.4] PHP Warning:  include()
[<a href='function.include'>function.include</a>]: Couldn't resolve host name
in /www/host/htdocs/roundcube/program/include/iniset.php on line 98

[Fri Jul 03 03:42:50 2009] [error] [client 1.2.3.4] PHP Warning:
include(rcube_user.php) [<a href='function.include'>function.include</a>]:
failed to open stream: operation failed in
/www/host/htdocs/roundcube/program/include/iniset.php on line 98
[Fri Jul 03 03:42:50 2009] [error] [client 1.2.3.4] PHP Warning:  include()
[<a href='function.include'>function.include</a>]: Failed opening
'rcube_user.php' for inclusion
(include_path='/www/host/htdocs/roundcube/:/www/host/htdocs/roundcube/program:/www/host/htdocs/roundcube/program/lib:/www/host/htdocs/roundcube/program/include:.:/usr/share/php5:/usr/share/php')
in /www/host/htdocs/roundcube/program/include/iniset.php on line 98

[Fri Jul 03 03:42:50 2009] [error] [client 1.2.3.4] PHP Fatal error:  Class
'rcube_user' not found in
/www/host/htdocs/roundcube/program/include/rcmail.php on line 122

Any hints?

Patrick.

--
(Continue reading)

Roland Liebl | 3 Jul 09:38 2009
Picon

[RCD] Database Table for Plugins

Hi all,

I think it might be a good idea to have a database table for plugins.

If plugins needs to store some values currently this is done
mostly by using 'users' table 'preferences' field.

I think it's better to have a separate table.

The following structure should be flexible enough.

------------------------------------------------------
CREATE TABLE IF NOT EXISTS `plugins` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL,
  `contact_id` int(11) DEFAULT NULL,
  `identity_id` int(11) DEFAULT NULL,
  `plugin` text,
  `key` text,
  `value` text,
  `timestamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--------------------------------------------------------
Any comments are welcome.
Regards,
Roland
_______________________________________________
List info: http://lists.roundcube.net/dev/
Thomas Bruederli | 3 Jul 15:42 2009
Picon

Re: [RCD] Plugin Template hooks

On Sat, Jun 27, 2009 at 01:10, Cor Bosman<cor <at> xs4all.nl> wrote:
> I looked at the code, and the template class seems like a perfect
> place to add a hook thats called after each template object and/or
> container. The interesting part is, there already is one!
>
> $hook = $this->app->plugins->exec_hook("template_container", $attrib);
>
> This hook is called with the container id as a parameter, and you can
> return content to add to the container. Unfortunately, it doesnt work,
> because RC uses the hook internally and doesnt play nice :) In
> function template_container_hook() it replaces the content instead of
> adding to it.

Fixed this in revison 2704. This hook can now also be used by other plugins.
>
> But, the spot where that hook is placed, is where we could have a
> before/after hook to add stuff to template objects and containers.
>
As Phil already mentioned, there's $RCMAIL->output->add_footer() and
->add_header() which can be used to insert content to the page head
and body section. I'm not sure if we really need a plugin hook that
does the same.

~Thomas
_______________________________________________
List info: http://lists.roundcube.net/dev/

till | 3 Jul 15:56 2009
Picon

Re: [RCD] php code design/performance

On Fri, Jul 3, 2009 at 5:55 AM, Andre<andre <at> neo-anime.org> wrote:
>
> On Thu, 2 Jul 2009 21:38:43 +0200, darklight
> <darklight.xdarklight <at> 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/ddfbe82dd80408cc
>

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.

 <at> 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/

Thomas Bruederli | 3 Jul 16:11 2009
Picon

Re: [RCD] Message archive plugin

On Mon, Jun 22, 2009 at 09:22, Roland Liebl<roland <at> roland-liebl.de> wrote:
> Is there a way to localize the "Archive" folder?

With the latest changes in r2705 this could be done like this:

// in init()
  $this->add_hook('list_mailboxes', array($this, 'list_mailboxes'));
  ...

// and the callback function:
  function list_mailboxes($p)
  {
    $rcmail = rcmail::get_instance();
    $archive_folder = $rcmail->config->get('archive_mbox');

    if ($archive_folder && $p['list'][$archive_folder])
      $p['list'][$archive_folder]['name'] = $this->gettext('archivefolder');

    return $p;
  }

I think I'll add the archive plugin (with the above changes) to our
SVN repository because it's also one of my favorites.

~Thomas
_______________________________________________
List info: http://lists.roundcube.net/dev/

Raoul Bhatia [IPAX] | 3 Jul 16:25 2009
Picon

[RCD] svn.roundcube.net certificate expired on 07/01/2009 03:18 PM

for https://svn.roundcube.net/

-> The certificate expired on 07/01/2009 03:18 PM.

cheers,
raoul
--

-- 
____________________________________________________________________
DI (FH) Raoul Bhatia M.Sc.          email.          r.bhatia <at> ipax.at
Technischer Leiter

IPAX - Aloy Bhatia Hava OEG         web.          http://www.ipax.at
Barawitzkagasse 10/2/2/11           email.            office <at> ipax.at
1190 Wien                           tel.               +43 1 3670030
FN 277995t HG Wien                  fax.            +43 1 3670030 15
____________________________________________________________________
_______________________________________________
List info: http://lists.roundcube.net/dev/


Gmane