为了账号安全,请及时绑定邮箱和手机立即绑定

如何检测 PHP JIT 是否启用

如何检测 PHP JIT 是否启用

PHP
慕妹3146593 2023-07-08 17:21:13
检测 PHP 是否使用 JIT 编译以及从运行脚本启用 JIT 的最简单方法是什么?
查看完整描述

3 回答

?
萧十郎

TA贡献1815条经验 获得超12个赞

您可以通过调用直接查询 opcache 设置opcache_get_status()


opcache_get_status()["jit"]["enabled"];

或在以下位置执行查找php.ini:


ini_get("opcache.jit")

这是一个整数(以字符串形式返回),其中最后一位数字表示 JIT 的状态:


0 - don't JIT

1 - minimal JIT (call standard VM handlers)

2 - selective VM handler inlining

3 - optimized JIT based on static type inference of individual function

4 - optimized JIT based on static type inference and call tree

5 - optimized JIT based on static type inference and inner procedure analyses

来源: https: //wiki.php.net/rfc/jit#phpini_defaults


查看完整回答
反对 回复 2023-07-08
?
慕妹3242003

TA贡献1824条经验 获得超6个赞

opcache_get_status()当 JIT 被禁用时将不起作用并会抛出致命错误。


echo (function_exists('opcache_get_status') 

      && opcache_get_status()['jit']['enabled']) ? 'JIT enabled' : 'JIT disabled';

我们必须在文件中对 JIT 进行以下设置php.ini。


zend_extension=opcache.so

opcache.enable=1

opcache.enable_cli=1 //optional, for CLI interpreter

opcache.jit_buffer_size=32M //default is 0, with value 0 JIT doesn't work

opcache.jit=1235 //optional, default is "tracing" which is equal to 1254


查看完整回答
反对 回复 2023-07-08
?
MMTTMM

TA贡献1869条经验 获得超4个赞

php -i | grep "opcache"


checking:

opcache.enable => On => On

opcache.enable_cli => On => On

opcache.jit => tracing => tracing


查看完整回答
反对 回复 2023-07-08
  • 3 回答
  • 0 关注
  • 175 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信