Re: Re: optimilize web page loading

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2008-03-29 at 10:16 +0100, Zoltán Németh wrote:
> >
> >  One last thing though...
> > even if this were escaped and even if there were fifty variables
> > embedded, a good bytecode optimizer (not quite the same as a bytecode
> > cacher) would optimize the bytecode for caching so that the string is
> > broken up according to what needs to be interpolated and what does not.
> 
> could you tell me more about this bytecode optimizer stuff? how does it
> work, how much better/faster is it then APC/EAccelerator/etc?

It really depends on what an optimizer optimizes. TurckMMCache had.has
an optimizer. Zend offers an optimizer too. Optimizer can work in a
number of ways. They may be an explicit part of the bytecode cache
mechanism or possibly plugged as one element in a chain of bytecode
processors... parser -> optmizer -> cacher. I'm not exactly sure how it
works for PHP.

The main difference between a cacher and an optimizer though is that
generally speaking a caher only deals with caching the bytecode. No
processing occurs on the produced bytecode. On the other hand an
optimizer may perform alterates on the bytecodes to enhance speed.

For example... by now most people on the list probably know that:

    ++$i;

Is faster than:

    $i++;

An optmizer might see $i++ and determine that the return value is not
used and thus the operation can be changed from $i++ to ++$i. Smilarly,
the optimizer might encounter the following expression:

    $foo = 1 << 8

And reduce the constant expression (1 << 8) to (256). So the expression
essentially becomes:

    $foo = 256

Similarly if you take the following expression:

    $text = "There was an old man from Nantuckit\n"
           ."Who's sole possession was a bucket.\n"
           ."One day with a grin,\n"
           ."While scratching his chin\n"
           ."He thought, \"I think I'll build a rocket.\"\n";

This could be optimized by removing concatenation operations and
producing a single unified string within the bytecode.

These are just basic optimizations obviously. Optimization is not a new
thing, if you've ever used the -O flags when building a C program then
you know that C compilers can also perform optimizations.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux