PHP OPcache优化级别-它们是什么? [英] PHP OPcache optimization levels - what are they?
问题描述
有一个 opcache.optimization_level php.ini指示.这是一个位掩码,默认为0xffffffff
-因此默认情况下,OPcache会进行所有优化.
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.
OPcache会进行哪种优化?字节码传递了什么?
What kind of optimizations does OPcache do? What passes on bytecode are done?
后续问题:OPcache是否可以很好地优化代码模式?例如,HHVM可以跳过仅包含类/函数声明的文件的执行,而仅填充类/函数表.
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.
推荐答案
opcache.optimization_level
的位对应于:
- 位0-传递1:
- CSE -消除常量子表达式
- ADD_CHAR/ADD_STRING优化的顺序
- 将CAST(IS_BOOL,x)转换为BOOL(x)
- 转换 INTI_FCALL_BY_NAME + DO_FCALL
- bit 0 - pass 1:
- CSE - constants subexpressions elimination
- Sequences of ADD_CHAR/ADD_STRING optimization
- convert CAST(IS_BOOL,x) into BOOL(x)
- convert INTI_FCALL_BY_NAME + DO_FCALL_BY_NAME into DO_FCALL
- Convert constant operands to expected types
- Convert conditional JMP with constant operands
- Optimize static BRK and CONT
- 将$ a = $ a + expr转换为$ a + = expr
- 将$ a ++转换为++ $ a
- 优化 JMP s 系列
- Convert $a = $a + expr into $a += expr
- Convert $a++ into ++$a
- Optimize series of JMPs
- 打印和ECHO优化-已删除
- 块优化(最昂贵的优化过程,它基于CFG执行许多不同的优化模式-控制流图)
- 注册分配(允许重新使用临时变量)
- register allocation (allows re-usage of temporary variables)
- 删除NOP
我环顾四周,看看是否可以在任何代码模式上找到比其他代码更好的东西,但是我没有任何运气.
I've looked around to see if I can find anything on any code patterns that it handles better than others, but I haven't had any luck.
来自 https://github.com/zendtech/ZendOptimizerPlus/blob/master/Optimizer的信息/zend_optimizer.c 和 https://gist.github.com/ck-on/4959032 ?ocp.php
这篇关于PHP OPcache优化级别-它们是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!