Rasmus Lerdorf wrote:
> Well, outside of an opcode cache, you wouldn't care whether the logic is
> in the compiler or the executor.  But once you introduce an opcode
> cache, anything that you can resolve at compile-time means one less
> thing to do at execute time which means that the feature essentially
> becomes free once the file has been compiled and cached.
>
> Current opcode caches, including APC, will replace class and function
> definitions with NOPs in the cached op_arrays when it can definitively
> resolve them at compile-time.  Things like autoload and conditional
> includes are examples of features that destroy this optimization because
> we need the runtime context in order to determine what to do which means
> we have to do it in the executor.  Then of course there is the nightmare
> of class inheritance spanning includes and code that sometimes includes
> a file containing a child class conditionally and other times
> unconditionally.  That caused us weeks, if not months, of headache in
> APC land.
>   
Hi,

I remember this anguish, and have been following closely APC development
through Gopal's blog, watching commit messages and so on, and have been
proposing changes to PEAR2 (admittedly extremely controversial ones)
that would make it more APC-friendly, so the last thing I want to do is
add headaches in APC land, quite the opposite.
>> I don't wish to cause trouble on these points, but I don't yet
>> understand how the patch makes things any worse for APC, as all of the
>> namespacing is still 100% deterministic and is a closed per-file system
>> done at compile-time.
>>     
>
> Perhaps it doesn't.  What worries me is the ability to change the
> namespace mid-file.  Maybe I can resolve this entirely at compile-time
> as long as no includes, imports or any other tricks can be used to break
> the namespace-to-one-file association.  And we especially have to avoid
> anything that would cause a single file to change namespaces depending
> on how it is included and where it is included from.
I understand this.

I guess the way I would answer this is to question how you think APC
would react differently to these two examples:

example 1:
file1.php:
<?php
namespace gronk;
class bar {}
?>

another.php:
<?php
namespace another;
class boo {}
?>

file2.php:
<?php
namespace foo;
include 'file1.php';
include 'another.php';
import gronk::bar;
class extender extends bar {}
?>

====

example 2:
file1.php:
<?php
namespace gronk;
class bar {}
?>

file2.php:
<?php
include 'file1.php';
namespace another {
    class boo {}
}
import gronk::bar;
namespace foo {
    class extender extends bar {}
}
?>

The two are functionally equivalent ways of doing things, the first
without my patch, and the second with it.  Would the second example's
file2.php cause greater difficulty for APC in your estimation?

Greg

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to