[wp-hackers] This is a Performance Enhancement? Clarification
wordpress at santosj.name
Thu Jan 7 23:15:52 UTC 2010
Well, that touches on something I had meant to clarify, but forgot to.
Compiling does not equal execution and is generally a fairly quick
process. It is only when you run functions, classes, and whatever that
it matters , so generally it shouldn't be considered that
conditionally including will speed anything up, even if for a tiny of
cases it won't be needed. The problem is that sometimes you can't get
around it without doing a lot of extra work and hassle that may include
You could replace the plugin inclusion by creating a PHP file that did
the inclusions of the plugins and was updated whenever the plugin page
was updated. This however, is a great deal more difficult and creates a
file for the sole purpose of replacing the database option. Sure, it
will be faster, but at the cost of complexity. Furthermore, you'll
probably still want to have a conditional to ensure that the site
doesn't break when plugins are deleted or moved. It is an balancing
between benefits of different factors vs performance and I would say
that it is better the way it is now. The overhead is smaller than the
work it would take to prevent having the overhead and would only
minimize the loop and database option. This is an example of where it
Where it doesn't make sense is to do it for performance, because it adds
overhead and something that adds overhead shouldn't be used to improve
performance. That is probably as close to the definition of crazy or
insane as one can get.
The PHP/Zend engine does not do JIT (as in compiling to machine code or
as close to machine code as possible, the PHP opcodes are not machine
specific but PHP engine specific). If you are using PHP compiled to MS
CLR and using the runtime to convert it to CIL, then that is probably as
close as you are going to get to JIT compilation. There are also some
outdated applications that will compile PHP down to C for creating an
Executable. However, for the small percentage that are doing that, then
good for them, the rest of us has to deal with the PHP/Zend Engine and
hopefully includes some opcode caching to offset some of the overhead of
 The function stack usually is what takes time during execution, but
when you add on top of that having to stop PHP to compile the function
and then create the stack, it doesn't perform as well. When it is all
done in the first stage then I'm a lot more happy. The vast majority of
WordPress with handling of Plugins really dogs this and I think some of
it was done for "performance" and there have been discussions of
conditionally including files to "speed" up WordPress before Ryan dug up
the sources that articulated that this was not the case, has never been
the case and that the opposite is true .
 The reason I'm being a jerk is so that hopefully people remember
this discussion and pass it along. I hate making people feel like fools
for being wrong, because hell I've been wrong, but on this topic, I'm
not. I would feel better if someone told me that I was wrong, so that I
don't get into a position talking to someone who knows better and
speaking as if I do as well. Some people are eventually going to go off
and try to get PHP programming jobs and not knowing your stuff makes you
look incompetent even before you can prove otherwise.
 Well, unless it is a junior or entry level position, then you aren't
exactly expected to know everything. Most likely if you only specialized
in WordPress development (plugin, theme, core), you probably don't
anyway. Good experience and looks great on a Resume, don't I believe it .
 I don't actually do a lot of WordPress work at my job. Actually, we
are migrating away from WordPress, which is bittersweet. Bitter because
I devoted a lot of my time to WordPress because of my job and sweet,
because the new code functions a lot better without limitations that
exist within WordPress .
 I still think WordPress does somethings better than many of the
frameworks out there.
> On Thu, Jan 7, 2010 at 3:08 PM, Jacob Santos <wordpress at santosj.name> wrote:
>> Myth 2. Conditional loading speeds up PHP.
>> The problem I have with the comment  is that it uses the myth that
>> conditional functions and file loading speeds up execution of PHP, when you
>> can not find a single source that will ever say this. In fact, all of them
>> will say that it slows down execution, because PHP has to stop the
>> execution, go back to the compile stage and then go back to the execution.
> Well, file loading on-the-fly has to do that anyway, right?
> I mean, not doing an include is always faster than doing the include
> *if* the cost of the include is higher than the cost of the comparison
> you're making to determine whether or not to do the include. Of
> course, if doing the include turns out to be the most common case,
> then your conditional might not be worth the trouble.
> And anyway, I thought most modern PHP executables did JIT compiling nowadays.
> Best is to design your code so that the include happens when it's
> known to be needed, but not earlier.
> I agree with you with regards to functions, and to how this sort of
> thing in general may hurt opcode cache systems.
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers