APC,磁盘命中以及要求/包含 [英] APC, disk hits, and requires/includes

查看:95
本文介绍了APC,磁盘命中以及要求/包含的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个非常简单的问题,但我实际上不能确定. PHP如何处理APC已缓存的文件的需求/包含?我的理解是,该缓存主要是节省了PHP来编译已经缓存的文件,但是对我来说还不清楚是否还保存了查找/获取文件所需的磁盘命中.是吗?还是即使操作码已经被缓存,PHP还是会击中磁盘,唯一的区别是它不会再次执行编译过程?

Pretty simple question, but I can't actually tell for sure. How does PHP behave with requires/includes of files that have been already cached by APC? My understanding is that this cache primarily saves PHP of compiling a file that has been already cached, but it's not clear to me whether it also saves the disk hit necessary to find/fetch the file aswell; so, does it? Or will PHP hit the disk, even if the opcode has been already cached, the only difference being that it doesn't do the compilation process again?

我想认为需求/包含神奇地知道了文件已缓存,因此多亏了APC,因此可以直接从内存中获取文件,但是我只是意识到我没有理由假设情况如此,所以我问为什么.

I would like to think requires/includes magically know a file is cached and thus fetch it directly from memory thanks to APC, but I just realized I have no reason to assume this is case, hence why I ask.

推荐答案

APC覆盖了Zend Engine中的zend_compile_file函数,该函数除其他功能外还负责查找和打开实际文件;因此,如果文件已经被缓存,它能够在磁盘命中之前劫持"磁盘命中.

APC overrides the function zend_compile_file in the Zend Engine, which among other things is responsible locating and opening the actual files; thanks to this it is able to "hijack" disk hits before they happen if the file is already cached.

因此,是的,如果文件被缓存,则会从内存中提供文件.

Therefore, yes, files are served from memory if cached.

来源: APC技术说明和Zend Engine源代码,特别是 zend_language_scanner.c

Sources: APC Technotes and the Zend Engine source code, specifically zend_language_scanner.c

这篇关于APC,磁盘命中以及要求/包含的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆