Re: How does the Zend engine behave?

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

 



Sean Pringle wrote:
>> The Caching systems such as Zend Cache (not the Optimizer), MMCache,
>> APC, etc are expressly designed to store the tokenized version of the
>> PHP script to be executed.
>>
>> Note that their REAL performance savings is actually in loading from
>> the hard drive into RAM, not actually the PHP tokenization.
>>
>> Skipping a hard drive seek and read is probably at least 95% of the
>> savings, even in the longest real-world scripts.
> 
> Interesting.  If PHP tokenization is such a small cost, what makes a
> special caching system better than the OS for caching files in memory
> after the first disk read?

APC actually executes the opcodes directly in shared memory, so unlike a
disk cache, you are not copying lots of stuff around.  APC does need to
copy some things down into process-local memory, but most can be left
where it is.  Disk caches also tend to expire pretty fast because
everything your OS does tends to touch the disk and when you application
starts eating memory your disk cache is the first to go when things get
tight.  With a dedicated shared memory segment that won't happen.
Things will stay put.

It is also possible to run APC in no-stat mode which means it will never
touch the disk at all.  If you are on an Intel cpu with an older OS like
freebsd4, disk-touching syscalls are massively slow and you can gain a
lot by skipping the up-to-date stat check on each request and include file.

Finally the compiler does more than just tokenize your script.  It will
cache functions and classes when it can and rewrite the opcodes so these
functions and classes won't have to be created at execution time.  Of
course, that assumes you haven't gone all framework-crazy and made
everything dynamic with autoload or weird conditional function and class
declarations.  If it becomes a runtime decision whether class or a
function is declared, or heaven forbid, the same class takes on
different signatures based on some runtime condition, then there isn't
much the compiler can do to speed that up.

-Rasmus

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