Page 1 of 1

Includes and APC

Posted: Mon Sep 24, 2007 7:20 pm
by Ambush Commander
Read this blog post, and then report back here.

I think I vaguely understand it. But I probably don't, since I haven't the foggiest idea of what I need to do to prevent this problem. Can anyone elucidate?

Posted: Mon Sep 24, 2007 7:49 pm
by Maugrim_The_Reaper
It's easy - stick everything into one file ;). Your performance will beat anything else needing includes.

Gopal's analysis is pure illumination. For the last two years people have been asking these questions and not getting a simple convincing answer. You should see where the PEAR2 debate over dropping *_once constructs as a requirement has gone over the last few months.

I think this illustrates one point - APC is screwing up a little. Yes, it works, but it's only going to work best when you put all your PHP classes into one giant file to be cached (Greg Beaver's benchmarking earlier today showed an incredible oddity running APC with stat=0 emphasising this). Otherwise, classes which inherit from as yet unmet parents, won't be as efficiently cached (parent not yet hit, so it requires additional opcode for later execution when the parent is finally available).

APC needs fixing - hopefully prior to being released in PHP6 publicly. Until then it's PEAR2 style out-the-window thinking (even if it unintuitively makes good sense right now).

Posted: Mon Sep 24, 2007 7:56 pm
by Ambush Commander
Interestingly enough, that's exactly what I've done. Go me! :-) (actually, it's a preprocessor the rolls up all the PHP files into one big one; works essentially the same way)

APC has it tough, since unlike Java where the one class per file convention is strictly enforced, PHP has no such rules. Which makes things complicated.

Posted: Mon Sep 24, 2007 9:08 pm
by Christopher
I thought there was discussion on the Zend Framework list about this and that they were going to address the include_once() problems in upcoming PHP5 releases? I have not used the _once() functions in a while because they have had problems since their conception. When they were first added they had separate file lists -- what a mess.

Posted: Tue Sep 25, 2007 3:54 am
by Maugrim_The_Reaper
PHP5.2 included some optimisations for the *_once functions (I think it was a realpath cache?) but the main problem above is with APC. So while PHP5.2 is faster for using *_once, APC still won't cache everything as efficiently as it could.

Not that the Zend Framework has ever seen XDebug anyway ;). I've never seen much of a concerted optimisation effort post 1.0.