opcache

php中的脚本加速扩展opcache (1)

ぃ、小莉子 提交于 2019-12-03 00:13:28
今儿在 azure 里装 php5.5.4 得瑟,发现原先 php5.4 、 php5.3 中的 zend guard laoder 以及 php5.2 中的 Zend Optimizer 均不能再用,一直很喜欢用的 eaccelerator 也悲剧了,编译的时候直接提示错误。 没办法,翻看 php5.5.4 的安装目录,发现 php 的安装目录下的扩展库目录有个 opcached.so ;咦,这个文件是搞毛线的?看名字带 cached ,难道是个缓存系统? google 了下,果不其然,这个是 php5.5 默认提供的 php 脚本缓存扩展,编译 php5.5 时加上参数 --enable-opcache 就可以编译 opcache 了,只是要启用的话必须配置。 一、 PHP 中 opcache 的安装、加速效果与配置介绍 经过测试, php5.4 、 php5.3 乃至 php5.2 也是可以使用 opcache 模块的,参考网络上的测试文章( http://www.cnblogs.com/xiaocen/p/3709850.html )发现: zend opcache( 一般就直接简称为 opcache 了 ) 的加速效率高于 xcache ,自然也就高于一年多不维护的 eaccelerator 了。另外,我的测试发现在 php5.4 上加载了 eaccelerator

Enable PHP 5.5 OPCache

隐身守侯 提交于 2019-12-01 22:12:24
问题 After configuring OPCache as recomanded, It's not working. So, How to debug OPCache to see where is the problem? Or I am missing something? My config: php.ini php -v And in code opcache_get_status(); // return false //but extension_loaded('Zend OPcache') // return true 回答1: It has been quite some time so I imagine you have moved on from this issue but in case you have not. Is noticed you are running Xdebug... Have you checked your php.ini to make sure that the following is not an issue? If

使用 Zend Opcache 加速 PHP (2)

自古美人都是妖i 提交于 2019-12-01 15:53:16
Optimizer+ 是 Zend 开发的闭源但可以免费使用的 PHP 优化加速组件,是第一个也是最快的 opcode 缓存工具。现在,Zend 科技公司将 Optimizer+ 在 PHP License 下开源成为 Zend Opcache。 Zend OPcache 通过 opcode 缓存和优化提供更快的 PHP 执行过程。它将预编译的脚本文件存储在共享内存中供以后使用,从而避免了从磁盘读取代码并进行编译的时间消耗。同时,它还应用了一些代码优化模式,使得代码执行更快。 1. 什么是 opcode 缓存? ¶ 当解释器完成对脚本代码的分析后,便将它们生成可以直接运行的中间代码,也称为操作码(Operate Code,opcode)。Opcode cache 的目地是避免重复编译,减少 CPU 和内存开销。如果动态内容的性能瓶颈不在于 CPU 和内存,而在于 I/O 操作,比如数据库查询带来的磁盘 I/O 开销,那么 opcode cache 的性能提升是非常有限的。但是既然 opcode cache 能带来 CPU 和内存开销的降低,这总归是好事 —— 本着环保的态度,也应该尽量减少消耗不是? :D 现代操作码缓存器(Optimizer+,APC2.0+,其他)使用共享内存进行存储,并且可以直接从中执行文件,而不用在执行前“反序列化”代码。这将带来显着的性能加速

Windows, XAMPP, PHP 7 and opcache

浪子不回头ぞ 提交于 2019-12-01 02:57:34
I've installed latest XAMPP server with PHP 7 (update: checked also PHP 7.1) (on my Windows 10 system). Wanted to use opcache , so I enabled it in php.ini . [opcache] zend_extension=php_opcache.dll opcache.enable=1 opcache.enable_cli=0 opcache.memory_consumption=128 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=4000 With that change now, and with almost every page refresh, I'm getting this error from Apache: AH00428: Parent: child process 3748 exited with status 3221226356 -- Restarting. So, page is loading, and loading... waiting to Apache start again. When I'm turning

How to use ZendOpCache for Doctrine2 cache?

烂漫一生 提交于 2019-11-30 20:03:21
I have installed PHP 5.5.1 in my development environment, and also have config Zend OpCache as Cache provider. Everything is working on the server with the new version and settings, but inside my symfony 2 project I have the Doctine2 cache to store some "static" data (countries, languages, etc) and it not works with Opcache. Until today, I was using the Doctrine\Common\Cache\ApcCache class to work with the cache of Doctrine2 using APC, but seems that does not exists a class to work with OpCache. This is my config.yml for APC cache: # Services services: cache: class: Doctrine\Common\Cache

What is userland caching APCu extension in PHP?

时光怂恿深爱的人放手 提交于 2019-11-30 16:24:49
问题 Just a question related to OPcache cause I didn't understand it and find an answer on Google: When we talk about userland caching, what does it mean? I know PHP is pre-bundled with the new Zend OPcache extension and that this extension caches op code into ram in order not to stress too much the processor which should convert to op code the PHP source at every request, but what about the APCu when they say that it implements userland caching? What is userland caching? Is it possible to keep

PHP OPcache optimization levels - what are they?

好久不见. 提交于 2019-11-30 10:59:29
问题 There is an opcache.optimization_level php.ini directive. It is a bitmask a defaults to 0xffffffff - so by default OPcache does all the optimizations. What kind of optimizations does OPcache do? What passes on bytecode are done? Follow-up question: is there a code pattern that OPcache can optimise very well? For example, HHVM can skip execution of files that contain only class/function declarations and it just fills class/function tables. 回答1: The bits of opcache.optimization_level correspond

How to use ZendOpCache for Doctrine2 cache?

霸气de小男生 提交于 2019-11-30 03:55:39
问题 I have installed PHP 5.5.1 in my development environment, and also have config Zend OpCache as Cache provider. Everything is working on the server with the new version and settings, but inside my symfony 2 project I have the Doctine2 cache to store some "static" data (countries, languages, etc) and it not works with Opcache. Until today, I was using the Doctrine\Common\Cache\ApcCache class to work with the cache of Doctrine2 using APC, but seems that does not exists a class to work with

Windows, XAMPP, PHP 7 and opcache

拜拜、爱过 提交于 2019-11-30 01:38:38
问题 I've installed latest XAMPP server with PHP 7 (update: checked also PHP 7.1) (on my Windows 10 system). Wanted to use opcache , so I enabled it in php.ini . [opcache] zend_extension=php_opcache.dll opcache.enable=1 opcache.enable_cli=0 opcache.memory_consumption=128 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=4000 With that change now, and with almost every page refresh, I'm getting this error from Apache: AH00428: Parent: child process 3748 exited with status 3221226356 -

PHP OPcache optimization levels - what are they?

让人想犯罪 __ 提交于 2019-11-29 22:59:36
There is an opcache.optimization_level php.ini directive. It is a bitmask a defaults to 0xffffffff - so by default OPcache does all the optimizations. What kind of optimizations does OPcache do? What passes on bytecode are done? Follow-up question: is there a code pattern that OPcache can optimise very well? For example, HHVM can skip execution of files that contain only class/function declarations and it just fills class/function tables. The bits of opcache.optimization_level correspond to: bit 0 - pass 1: CSE - constants subexpressions elimination Sequences of ADD_CHAR/ADD_STRING