This topic has come up a few other times on this list in the last few
months so I thought I'd try to sumarize some of those points on this issue:
Arnoud Limbourg posted a link in the "Do we really need
Zend::exception()?" thread to this blog which seems to have the most
convincing evidence I've seen for why not to use autoload or other types
of conditional includes if you are using an op-code cache:
http://pooteeweet.org/blog/538
Richard Thomas posted some benchmark results for an extremely simple
"hello world" app in the thread "Performance testing" that showed
improvements by getting rid of as many require_once calls as possible.
It seems that the requirements are going to be different for advanced
users that use an opcode cache and for those who don't use an opcode
cache and would benefit from the simplicity of autoload and less
require_once calls.
I think part of the concern with adding autoload directly into the
framework is that developers might want their autoload function to
include additional logic to allow it to work with their other
libraries. Not really sure what the answer is here... perhaps to
clearly show how to create an autoload function in the bootstrap file in
the tutorials and documentation so that newbies can copy and paste it in
and be ready to go. In terms of the conditional include problem with
opcode caches... maybe as Lars suggested, it's up to those advanced
users to add the include statements to the bootstrap file to make sure
that they get cached properly.
Several people have posted about not wanting to get too much into
performance tweaking until the framework has neared version 1.0 and that
Zend plans on running it through their advanced testing setup at that
point. I guess autoloading isn't just about performance, it's about
convenience and easy of use too...
Thanks,
Rob
Laurent TAUPIAC wrote:
I'm using sp_autoload with APC on a pretty loaded site without any
problem.
Require_once/include_once is really slow... even if it s better in
5.2, it s still really slower than require or include. Autoload allow
you to use basic include or require instead of the 'once' version.
So, even if there is a little overload for autoload, it is less than
the overload burned by the 'once' mechanics.
Furthermore, include a file with an absolute path is really more
efficient than relative because you don't rely on include_path. (Try
to trace system calls to see how much it s differents)
Using include or include_once with absolute path is not that easy in a
framework. But it s really simple with autoload because you only have
to manage prefix on autoload function.
Autoload will allow you to include only what is needed, and don't lost
time to manage the include section. If you are using a debug lib, you
won't forget the include in source because you never call it in
production then you don't autoload it.
- sp_autoload allow to have multiple loader function.
- The little overload used by autoload function is less important than
the gain it give when using absolute include and save unused include
(like old forgotten lib, debug lib or exceptions that are loaded but
barely used)
- You can use auto_prepend to init autoload, then you don't even think
about class loading.
Lars Strojny a écrit :
Hi,
Am Sonntag, den 07.01.2007, 05:00 -0500 schrieb Shekar C Reddy:
I see at least one benefit to using autoload - load classes only
as-needed. Changes to code/framework frequently need a re-visit to the
require*() calls to see if any classes are loaded superfluously. Some
classes loaded superfluously could load additional classes that may
also be superfluous in a dynamic situation. But I'm still not clear
with op-code caches as some say they had issues while others say they
had no problems using them with autoload. Maybe, these got resolved
with the later versions of PHP/op-code caches?
To clear this thing up a bit: I'm using XCache with many of my projects
and I can state that it works fine with autoload. You can see cached
files in the stats which are just loaded via autoload. So no problem
there. This also means, that there is no general problem with
__autoload() and op-caches but potentially some of the caches out there
have problems. But then we have the situation that they need to fix it.
There is no need to work around buggy software. Can someone states
similiar informations for eaccellerator, then Zend thingy and APC?
Greets, Lars
--
---------------------------------------------------------------------
Sorry, This disclamer is auto added by FW's company
---------------------------------------------------------------------
------------------------------------------------------------------------
Si vous n'etes pas destinataires de ce message, merci d'avertir l'expediteur de
l'erreur de distribution et de le detruire immediatement.
Ce message contient des informations confidentielles ou appartenant a La
Francaise des Jeux. Il est etabli a l'intention exclusive de ses destinataires.
Toute divulgation, utilisation, diffusion ou reproduction (totale ou partielle)
de ce message ou des informations qu'il contient, doit etre prealablement
autorisee.
Tout message electronique est susceptible d'alteration et son integrite ne peut
etre assuree. La Francaise des Jeux decline toute responsabilite au titre de ce
message s'il a ete modifie ou falsifie.
If you are not the intended recipient of this e-mail, please notify the sender
of the wrong delivery and delete it immediately from your system.
This e-mail contains confidential information or information belonging to La
Francaise des Jeux and is intended solely for the addressees. The unauthorised
disclosure, use, dissemination or copying (either whole or partial) of this
e-mail, or any information it contains, is prohibited.
E-mails are susceptible to alteration and their integrity cannot be guaranteed.
La Francaise des Jeux shall not be liable for this e-mail if modified or
falsified.