Login | Register
My pages Projects Community openCollabNet

Discussions > dev > Re: [propel-dev] Propel 2.0 spl_autoload

propel
Discussion topic

Back to topic list

Re: [propel-dev] Propel 2.0 spl_autoload

Reply

Author =?ISO-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com>
Full name =?ISO-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com>
Date 2006-10-01 08:47:42 PDT
Message > However, according to what I've read, the hit it *slight* and not
> *huge*. But how can I know until I see numbers that actually test
> the require_once part. This means setting up a bare-bones example
> without large code (as compiling time masks the true hit of the
> _once call). Or better yet, some profiling numbers of the same code
> running with require vs. require_once and looking at the results.

Prior to 5.2 and the latest APC, _once calls were not accelerated _at
all_ by APC because there was no way for a cache to hook in.


> My worry is that people are starting to thing require_once is slow
> *in general* which it isn't. I believe that it is slower with
> opcode caches (although I don't see why, granted I haven't looked
> into it and I'm sure it's complicated).

It is slower than a regular require. I recently threw out all but one
_once call from Agavi, and with APC (on 5.0.4), the page rendering
time dropped by 50(!) percent.


> I am concerned that wholesale replacement of _once with the non-
> _once versions is a bad idea. They are not logically equivalent on
> their face!
>
> Before we go and make such a change, I'd like to have a discussion
> about it.
>
> - One option suggested was that require_once inside of autoload is
> redundant; that since it's autoload you can be sure that you'll
> only load a file exactly once anyway, b/c once it's loaded autoload
> () won't get called again for that class or any other class in that
> file.

Of course. Using _once inside an autoload is utterly stupid. Why
would you do that. It only gets called when the class was not found
anyway ;)

I emailed the APC dev list during the discussion in the other thread,
and Rasmus said that while dynamic/conditional loads (e.g. a require
inside an if, or an autoload) are accelerated by APC, too, there
won't be the same amount of improvement over a straight require(). I
still believe that autoload is the better solution; not only because
it makes things cleaner, but also because it offers the most fine-
grained JIT-style loading you could possibly have with next to no
effort as opposed to require calls, where you might end up loading
more than you need in the specific situation.


> - Another option is to write your own require_once. I kinda did
> this for one of my projects, and it works. I think the reason
> require_once is goofy is that it handles a lot of situations that
> most code would not need to rely on. For instance, if one does
> "require_once 'a/b/c.php', and there are 5 directories in
> include_path, then technically there are 5 different solutions to
> that require_once. I am guessing maybe that a lot of the quirkiness
> of the _once calls is dealing with stuff like this. I wrote my own
> require once that implements the _once part simply by keeping track
> of whether or not that exact string has been included before, and
> if so, simply exits, and if not, calls the non-_once counterpart to
> require/include it. This seems to work functionally, and seems that
> also it might avoid the _once hit discussed on the opcode cache
> forums.

We had some guys on #agavi who did that since APC prior to PHP 5.2
would randomly produce errors about classes not found - turned out
the _once stuff was the problem.


David

« Previous message in topic | 7 of 40 | Next message in topic »

Messages

Show all messages in topic

Propel 2.0 spl_autoload Cameron Brunner <cameron dot brunner at gmail dot com> Cameron Brunner <cameron dot brunner at gmail dot com> 2006-10-01 01:50:23 PDT
     Re: [propel-dev] Propel 2.0 spl_autoload hlellelid Hans Lellelid 2006-10-01 06:10:24 PDT
         Re: [propel-dev] Propel 2.0 spl_autoload Alan Pinstein <apinstein at mac dot com> Alan Pinstein <apinstein at mac dot com> 2006-10-01 08:08:20 PDT
         Re: [propel-dev] Propel 2.0 spl_autoload Cameron Brunner <cameron dot brunner at gmail dot com> Cameron Brunner <cameron dot brunner at gmail dot com> 2006-10-02 22:41:01 PDT
     Re: [propel-dev] Propel 2.0 spl_autoload =?ISO-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com> =?ISO-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com> 2006-10-01 07:22:51 PDT
     Re: [propel-dev] Propel 2.0 spl_autoload Alan Pinstein <apinstein at mac dot com> Alan Pinstein <apinstein at mac dot com> 2006-10-01 08:36:02 PDT
         Re: [propel-dev] Propel 2.0 spl_autoload =?ISO-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com> =?ISO-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com> 2006-10-01 08:47:42 PDT
             Re: [propel-dev] Propel 2.0 spl_autoload Alan Pinstein <apinstein at mac dot com> Alan Pinstein <apinstein at mac dot com> 2006-10-01 09:18:14 PDT
             Re: [propel-dev] Propel 2.0 spl_autoload Pedram Nimreezi <zenstyle at gmail dot com> Pedram Nimreezi <zenstyle at gmail dot com> 2006-10-01 09:38:18 PDT
                 Re: [propel-dev] Propel 2.0 spl_autoload =?ISO-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com> =?ISO-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com> 2006-10-01 09:50:26 PDT
                     Re: [propel-dev] Propel 2.0 spl_autoload Pedram Nimreezi <zenstyle at gmail dot com> Pedram Nimreezi <zenstyle at gmail dot com> 2006-10-01 09:59:57 PDT
                         Re: [propel-dev] Propel 2.0 spl_autoload Alan Pinstein <apinstein at mac dot com> Alan Pinstein <apinstein at mac dot com> 2006-10-01 10:40:56 PDT
                             Re: [propel-dev] Propel 2.0 spl_autoload =?ISO-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com> =?ISO-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com> 2006-10-01 10:50:02 PDT
                                 Re: [propel-dev] Propel 2.0 spl_autoload Alan Pinstein <apinstein at mac dot com> Alan Pinstein <apinstein at mac dot com> 2006-10-01 11:19:50 PDT
                                     Re: [propel-dev] Propel 2.0 spl_autoload Pedram Nimreezi <zenstyle at gmail dot com> Pedram Nimreezi <zenstyle at gmail dot com> 2006-10-01 12:35:38 PDT
                                         Re: [propel-dev] Propel 2.0 spl_autoload Alan Pinstein <apinstein at mac dot com> Alan Pinstein <apinstein at mac dot com> 2006-10-01 14:50:44 PDT
                                             Re: [propel-dev] Propel 2.0 spl_autoload Pedram Nimreezi <zenstyle at gmail dot com> Pedram Nimreezi <zenstyle at gmail dot com> 2006-10-01 20:09:57 PDT
         Re: [propel-dev] Propel 2.0 spl_autoload Cameron Brunner <cameron dot brunner at gmail dot com> Cameron Brunner <cameron dot brunner at gmail dot com> 2006-10-02 22:51:24 PDT
             Re: [propel-dev] Propel 2.0 spl_autoload =?ISO-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com> =?ISO-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com> 2006-10-03 03:44:33 PDT
                 Re: [propel-dev] Propel 2.0 spl_autoload Soenke Ruempler <soenke at ruempler dot eu> Soenke Ruempler <soenke at ruempler dot eu> 2006-10-03 04:04:09 PDT
             Re: [propel-dev] Propel 2.0 spl_autoload Alan Pinstein <apinstein at mac dot com> Alan Pinstein <apinstein at mac dot com> 2006-10-03 05:53:17 PDT
                 Re: [propel-dev] Propel 2.0 spl_autoload =?ISO-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com> =?ISO-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com> 2006-10-03 06:11:27 PDT
                     Re: [propel-dev] Propel 2.0 spl_autoload Alan Pinstein <apinstein at mac dot com> Alan Pinstein <apinstein at mac dot com> 2006-10-03 06:19:24 PDT
                 Re: [propel-dev] Propel 2.0 spl_autoload Cameron Brunner <cameron dot brunner at gmail dot com> Cameron Brunner <cameron dot brunner at gmail dot com> 2006-10-03 07:30:28 PDT
                     Re: [propel-dev] Propel 2.0 spl_autoload Alan Pinstein <apinstein at mac dot com> Alan Pinstein <apinstein at mac dot com> 2006-10-03 07:57:51 PDT
Page: of 2 « Previous | Next »
Messages per page: