I've just checked into APC CVS preliminary support for Lazy Loading classes and 
functions.  This means that rather than copying function entries into 
EG(function_table) and EG(class_table) when an include happen it will mark the 
functions/classes as available and only actually insert them into the tables 
when they are called.  This is done via hooks added into the various hash table 
lookups in PHP.  I've placed a patch for PHP_5_3 at:

http://tekrat.com/downloads/bits/apc_lazy_php53.patch

You should be able to apply the above patch to the latest PHP_5_3 branch, and 
recompile the latest APC CVS against it.  Two ini settings enable/display lazy 
loading:

apc.lazy_functions=On/Off
apc.lazy_classes=On/OFf

There's still some enhancements that I need to make in both PHP and APC for 
cleaner code and optimizations, but I wanted to get some early feedback to 
track down issues.  In a final version I'd prefer the above patch to abstract 
all function lookups into a common function.  I would love to hear about 
success/problems with this, as well as performance results or other 
suggestions.   This was initially implement for Facebook's codebase, and 
dropped CPU usage by about 30%, today it's required for the site to operate 
normally.  Although I expect smaller gains than this in other codebases 
(wordpress looks to be about 3%, Joomla and Zend Framework use autoloading and 
appear to get no visible gains).

Alternative implementations would include replacing the function entries with 
an internal function that would load the opcodes when called, however I found 
this implementation to be problematic, still requires changes to PHP, and would 
also require inserting entries into the function/class tables which itself ends 
up being an expensive task for extremely large codebases.

I look forward to hearing your feedback,

-shire

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to