Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP accelerator vs Just in Time Compilation

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?

like image 621
user734027 Avatar asked May 09 '11 23:05

user734027


People also ask

Is PHP a JIT?

PHP 8.0 brings support for Just-In-Time Compilation (JIT). Pure interpreted programming languages has no compilation step, and directly executes the code in a virtual machine. Most of the interpreted languages including PHP, in fact, has a light-weight compilation step to improve its performance.

What do you understand about PHP accelerator?

A PHP accelerator is a PHP extension that improves the performance of PHP apps. These extensions work by caching opcode (or operation code) generated by PHP files. For this reason, PHP accelerators are also referred to as Opcode Caching.

Why use JIT compiler?

The JIT compiler helps improve the performance of Java programs by compiling bytecodes into native machine code at run time. The JIT compiler is enabled by default. When a method has been compiled, the JVM calls the compiled code of that method directly instead of interpreting it.

What is APCu PHP?

APCu is an in-memory key-value store for PHP. Keys are of type string and values can be any PHP variables. APCu only supports userland caching of variables. APCu is APC stripped of opcode caching. The first APCu codebase was versioned 4.0.


1 Answers

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.

like image 70
Charles Avatar answered Sep 25 '22 02:09

Charles