Re: [APC-DEV] APC and autoloading

From: Date: Mon, 25 Sep 2006 08:22:00 +0000
Subject: Re: [APC-DEV] APC and autoloading
References: 1  Groups: php.apc.dev 
Request: Send a blank email to php-apc-dev+get-9@lists.php.net to get a copy of this message
David Zülke wrote:
Hi folks, I hope this is the right place for my question ;) Over at the Propel (http://propel.phpdb.org) Dev Mailing List, we're discussing moving to autoloading completely. Someone then mentioned the following ticket: http://pecl.php.net/bugs/bug.php?id=8765 Is it indeed accurate that APC doesn't accelerate _anything_ if a class is loaded via autoloading? I know it doesn't work well with _onces, but PHP 5.2 fixes that from what I understand. I always thought autoloading was the way to go, since it's not doing a _once (for obvious reasons), and it's only loading stuff on demand, so I assumed it to be the fastest of all possible solutions. I'd greatly appreciate any insight on this "issue".
Gopal summed it up nicely. It boils down to the fact that anything you push down into the executor is going to be slower than the same thing done in the compile phase. This is not an APC-specific thing, but a generic characteristic of any cache that caches the output of the compile phase. Any sort of runtime definition of classes or functions is going to be slower than compile-time. It's not hard to figure out what will be slow and what won't be. Just think about whether something can be completely defined without actually executing your script. eg. <?php class foo() { } ?> can be defined at compile-time. <?php if(cond) (
    class foo() { }{
} ?> can't be, since we have to execute the script to evaluate the condition before we know whether we should create the class. -Rasmus

« previous php.apc.dev (#9) next »