On Feb 21, 2009, at 4:10 PM, shire wrote:
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.

Wait... so if I understand this right, let's envision a code base where, per some random page load, 70 functions are actually called, but, oh, 7,000, or even 700,000, are being included for whatever reason?

The speed optimization is in *not* copying a massive amount of things that weren't even needed, or used, in the first place?

However, there's still the horribly massive speed hit of semi- loading, and marking, a fairly large amount of unused, un-needed, functions, as available?

While I do see, and understand, the performance benefit of such a coding direction, it's not exactly encouraging well designed code.

For example:
<?php
include(mega-loader.php);
//which kicks off
->include(site-mega-loader.php);
//which kicks off
-->include(sub-site-mega-loader.php);
//which kicks off
--->include(sub-site-application-loader.php);
//which kicks off
---->include(sub-site-application-feature-loader.php);
//which kicks off
----->include(sub-site-application-function-loader.php);
//which kicks off
------>include(sub-site-application-function-loader-function.php);

//and the actual code which caused the load?
my_custom_site_application_echo( "Hello World");

?>

This.... does not make me happy as a coder.

I do see the benefit of lazy loading, I'm just not very comfortable with enabling a philosophy of loading up a massive amount of CPU and RAM with "just in case they're wanted" features and code in the first place.

It *should* hurt to load something.

Code should not be ever loaded unless needed.

It certainly can boost an APC code set such as facebook, where many of those files and functions *will* likely be used in the next 20 minutes or so, but I also fear that it will encourage programmers to load everything they have, every time, just in case they need it.... and 2Gb apache processes (and APC space) can be.... ugly.

That being said, I think the idea is good, but the possible mis-uses are potentially tough issues.

-Bop

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

Reply via email to