PHP 加速器与即时编译

发布于 2024-11-05 21:26:39 字数 389 浏览 1 评论 0原文

来自维基百科:

大多数 PHP 加速器通过缓存 PHP 编译后的字节码来工作 脚本以避免解析和编译源代码的开销 每个请求(其中部分或全部可能永远不会被执行)。到 进一步提高性能,缓存的代码存储在共享中 内存并直接从那里执行,最大限度地减少缓慢的量 运行时的磁盘读取和内存复制。

及时编译:

JIT 编译器代表一种混合方法,进行翻译 连续地,就像口译员一样,但是缓存翻译后的内容 代码以尽量减少性能下降。

因此,在 PHP 上使用 APC 等 PHP 加速器对性能的影响与“即时”编译 PHP 的性能相同(假设可以这样做)……事实上,它们实际上是同一件事吗?

from wikipedia:

Most PHP accelerators work by caching the compiled bytecode of PHP
scripts to avoid the overhead of parsing and compiling source code on
each request (some or all of which may never even be executed). To
further improve performance, the cached code is stored in shared
memory and directly executed from there, minimizing the amount of slow
disk reads and memory copying at runtime.

Just in time Compilation:

JIT compilers represent a hybrid approach, with translation occurring
continuously, as with interpreters, but with caching of translated
code to minimize performance degradation.

so is using PHP accelerators such as APC on PHP have equivalent implications towards performance with "Just-in-time" compiling PHP (assuming that it's possible to do so)....in fact are they actually the same thing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往事随风而去 2024-11-12 21:26:39

因此,在 PHP 上使用 APC 等 PHP 加速器对性能的影响与“即时”编译 PHP 的性能相同(假设可以这样做)……事实上,它们实际上是同一件事吗?

相同的理念,不同的执行。

当大多数圈子中提到 JIT 时,它指的是将虚拟机字节码编译为本机字节码。例如,Facebook 的 HHVM 是一个使用 HHVM 的 PHP 实现。 hhvm.com/blog/2027/faster-and-cheaper-the-evolution-of-the-hhvm-jit" rel="nofollow">JIT 引擎。

然而,PHP 的本机虚拟机不会对本机字节码执行 JIT。事实上,它根本不做传统意义上的JIT。虽然整个文件按需编译为 PHP 字节码,但这实际上并不是 JIT。

请小心“PHP 加速器”一词。回到 PHP4 时代,PHP 解析器创建的字节码可以进行一些优化以获得更好的性能。从早期的 PHP5 开始就不需要了。 APC、Zend“优化器”和其他“加速器”产品为提高 PHP 性能所做的唯一就是缓存字节码。术语“加速器”不应再用于消除歧义。

如果您使用标准 PHP,那么您确实需要字节码缓存,只需避开声称尝试进行 PHP 字节码优化的产品即可。

so is using PHP accelerators such as APC on PHP have equivalent implications towards performance with "Just-in-time" compiling PHP (assuming that it's possible to do so)....in fact are they actually the same thing?

Same concept, different execution.

When JIT is spoken of in most circles, it refers to compiling virtual machine bytecode into native bytecode. For example, Facebook's HHVM is a PHP implementation that uses a JIT engine.

However, PHP's native virtual machine doesn't do JIT to native bytecode. In fact, it doesn't do JIT at all in the traditional sense. While whole files are compiled to PHP bytecode on-demand, this isn't actually JIT.

Be careful with the term "PHP accelerator." Back in the PHP4 days, the bytecode created by the PHP parser could be optimized a bit to get better performance. This hasn't been needed since early PHP5. The only thing that APC, the Zend "Optimizer" and other "accelerator" products do to increase PHP performance is cache bytecode. The term "accelerator" should no longer be used to remove ambiguity.

If you're using standard PHP, then you do want a bytecode cache, just steer clear of products saying that they try to do PHP bytecode optimization.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文