Jump to content

PHP accelerator

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 124.189.66.66 (talk) at 02:17, 4 December 2010 (Practical benefits). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

A PHP accelerator is a PHP extension designed to improve the performance of software applications written in the PHP programming language.

Operation

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.

Practical benefits

PHP accelerators can substantially increase the speed of PHP applications. Improvements of web page generation throughput by factors of 2 to 7 have been observed[1][2][3]. 50 times faster for compute intensive analysis programs[4].

The effect on application performance of opcode caching varies widely, depending on factors such as the inherent execution time of the PHP application and the percentage of source code actually executed on a given request, and whether additional optimization steps are performed. While a code optimizer may even slow down overall performance when used in isolation, it can provide an additional performance boost when coupled with a bytecode cache, as the optimization effort is performed just once.

PHP compiles your source code into memory as opcode then the accelerator saves the opcode. All your comments are deleted. Long variable names are reduced to tiny tokens. Unreadable cryptic code might shrink by a small amount. Well documented code with meaningful variable names and nice easy to read spacing might shrink to 100th or 1000th of the original size. Only the tiny opcode is stored in memory, not the big source code file. Each Web page request reads only the tiny opcode file and reads it direct from memory. Documentation is no longer a performance issue. An opcode cache lets you truly express your inner self freely with masses of elegant documentation in the code files without impacting on performance. Go forth and document!

See also

References

  1. ^ "PHP on Windows: The WinCache 1.0 Benchmark". Retrieved 2 September 2010.
  2. ^ "Benchmarking Drupal with PHP op-code caches: APC, eAccelerator and XCache compared". Retrieved 2 September 2010.
  3. ^ "Performance of Yii". Retrieved 2 September 2010.
  4. ^ "PHP performance". Retrieved 2 Dectember 2010. {{cite web}}: Check date values in: |accessdate= (help)