Sorry if this is basic, I am trying to learn as much as I can about OO in PHP and I am slowly learning how to use it (very limited).
对不起,如果这是基本的,我正在尝试尽可能多地学习PHP中的OO,我正在慢慢学习如何使用它(非常有限)。
So I am wanting to know if __autoload() has any affect on PHP opcode cache's?
所以我想知道__autoload()是否对PHP操作码缓存有任何影响?
2 个解决方案
#1
16
(Disclaimer : I only know APC)
(免责声明:我只知道APC)
What an opcode cache do is :
操作码缓存的作用是:
- when a file is included/required, it take the full path to that file
- check if the opcodes corresponding to that file are already in RAM (in opcode cache)
- if yes, return those opcode so they are executed
- if no, load the file and compile it to opcodes ; and store opcodes in cache.
如果是,返回那些操作码,以便它们被执行
如果不是,加载文件并将其编译为操作码;并将操作码存储在缓存中。
当包含/需要文件时,它将获取该文件的完整路径
检查对应于该文件的操作码是否已经在RAM中(在操作码缓存中)如果是,返回那些操作码,如果没有则执行它们,加载文件并将其编译为操作码;并将操作码存储在缓存中。
The important point, here, is the entry point : the full path to the file.
这里重点是入口点:文件的完整路径。
What autoloading generally do is :
自动加载通常做的是:
- get the name of a class
- transform it to the name of a file
- include/require that file
得到一个类的名称
将其转换为文件名
包含/要求该文件
So, the informations that are relevant for the opcode cache (full path to the file, and the fact that it is included/required) are still here.
因此,与操作码缓存相关的信息(文件的完整路径以及它包含/需要的事实)仍然存在。
In consequence, autoload shouldn't bring any trouble with op code caching.
因此,自动加载不会给操作码缓存带来任何麻烦。
(And, when using APC, it doesn't, as far as I can tell)
(并且,当使用APC时,据我所知,它没有)
#2
27
Opcode caches work (or at least should work) with autoloading but you can potentially take a performance hit from.
操作码缓存通过自动加载工作(或者至少应该工作)但是你可能会受到性能影响。
From Remember: be nice to byte code caches:
来自Remember:对字节码缓存很好:
<arnaud_> does autoload have a performance impact when using apc ?
<Rasmus_> it is slow both with and without apc
<Rasmus_> but yes, moreso with apc because anything that is autoloaded is pushed down into the executor
<Rasmus_> so nothing can be cached
<Rasmus_> the script itself is cached of course, but no functions or classes
<Rasmus_> Well, there is no way around that
<Rasmus_> autoload is runtime dependent
<Rasmus_> we have no idea if any autoloaded class should be loaded until the script is executed
<Rasmus_> top-level clean deps would speed things up a lot
<Rasmus_> it's not just autoload
<Rasmus_> it is any sort of class or function declaration that depends on some runtime context
<Rasmus_> if(cond) function foo...
<Rasmus_> if(cond) include file
<Rasmus_> where file has functions and classes
<Rasmus_> or heaven forbid: function foo() { class bar { } }
and this mail from Ramus:
来自Ramus的这封邮件:
To clarify, of course conditionally included files get compiled and cached. The issue is not the included files but the resulting conditionally defined classes and functions needing to be redefined on every request. Whether that is significant or not comes down to the specifics of the situation, but there is no doubt that it is slower. It comes down to a NOP vs. a FETCH_CLASS, for example and the NOP is obviously way faster.
为了澄清,当然有条件包含的文件被编译和缓存。问题不是包含的文件,而是需要在每个请求上重新定义的结果有条件定义的类和函数。这是否重要取决于具体情况,但毫无疑问它的速度较慢。例如,它归结为NOP与FETCH_CLASS,而NOP显然更快。
#1
16
(Disclaimer : I only know APC)
(免责声明:我只知道APC)
What an opcode cache do is :
操作码缓存的作用是:
- when a file is included/required, it take the full path to that file
- check if the opcodes corresponding to that file are already in RAM (in opcode cache)
- if yes, return those opcode so they are executed
- if no, load the file and compile it to opcodes ; and store opcodes in cache.
如果是,返回那些操作码,以便它们被执行
如果不是,加载文件并将其编译为操作码;并将操作码存储在缓存中。
当包含/需要文件时,它将获取该文件的完整路径
检查对应于该文件的操作码是否已经在RAM中(在操作码缓存中)如果是,返回那些操作码,如果没有则执行它们,加载文件并将其编译为操作码;并将操作码存储在缓存中。
The important point, here, is the entry point : the full path to the file.
这里重点是入口点:文件的完整路径。
What autoloading generally do is :
自动加载通常做的是:
- get the name of a class
- transform it to the name of a file
- include/require that file
得到一个类的名称
将其转换为文件名
包含/要求该文件
So, the informations that are relevant for the opcode cache (full path to the file, and the fact that it is included/required) are still here.
因此,与操作码缓存相关的信息(文件的完整路径以及它包含/需要的事实)仍然存在。
In consequence, autoload shouldn't bring any trouble with op code caching.
因此,自动加载不会给操作码缓存带来任何麻烦。
(And, when using APC, it doesn't, as far as I can tell)
(并且,当使用APC时,据我所知,它没有)
#2
27
Opcode caches work (or at least should work) with autoloading but you can potentially take a performance hit from.
操作码缓存通过自动加载工作(或者至少应该工作)但是你可能会受到性能影响。
From Remember: be nice to byte code caches:
来自Remember:对字节码缓存很好:
<arnaud_> does autoload have a performance impact when using apc ?
<Rasmus_> it is slow both with and without apc
<Rasmus_> but yes, moreso with apc because anything that is autoloaded is pushed down into the executor
<Rasmus_> so nothing can be cached
<Rasmus_> the script itself is cached of course, but no functions or classes
<Rasmus_> Well, there is no way around that
<Rasmus_> autoload is runtime dependent
<Rasmus_> we have no idea if any autoloaded class should be loaded until the script is executed
<Rasmus_> top-level clean deps would speed things up a lot
<Rasmus_> it's not just autoload
<Rasmus_> it is any sort of class or function declaration that depends on some runtime context
<Rasmus_> if(cond) function foo...
<Rasmus_> if(cond) include file
<Rasmus_> where file has functions and classes
<Rasmus_> or heaven forbid: function foo() { class bar { } }
and this mail from Ramus:
来自Ramus的这封邮件:
To clarify, of course conditionally included files get compiled and cached. The issue is not the included files but the resulting conditionally defined classes and functions needing to be redefined on every request. Whether that is significant or not comes down to the specifics of the situation, but there is no doubt that it is slower. It comes down to a NOP vs. a FETCH_CLASS, for example and the NOP is obviously way faster.
为了澄清,当然有条件包含的文件被编译和缓存。问题不是包含的文件,而是需要在每个请求上重新定义的结果有条件定义的类和函数。这是否重要取决于具体情况,但毫无疑问它的速度较慢。例如,它归结为NOP与FETCH_CLASS,而NOP显然更快。