Facebook improvements to the PHP

PHP is an interpreted language in the traditional sense, rather than a compiled language.

Therefore, before the command line or Web server to call the interpreter interpret PHP code, PHP code is PHP code. PHP PHP script interpreter interprets, converts the code series Zend opcode (machine code instructions, http://php.net/manual/internals2.opcodes.php ), then these opcodes to execute Zend Engine. However, the speed of execution of interpreted languages slower than compiled languages, because every code written in interpreted languages execution will need to convert it into machine code, the additional consumption of system resources. Facebook is aware of the performance bottleneck, and in 2010 began to develop a called HPHPc compiler to compile PHP code into C ++ code.

HPHPc compiler first PHP code is compiled into C ++ code , then C ++ code compiled into an executable file , and finally put the executable file is deployed to a production server . HPHPc largely successful, it improves Facebook performance, reducing the Facebook server burden. However, HPHPc enhance the performance has reached the limit and can not be fully compatible with PHP language, if needed extra time to compile, so the developers, the feedback loop is too long. Facebook needs a hybrid solution, it is necessary to further improve performance, but also allows developers faster, eliminating the need for time to compile the code.

So, Facebook began to develop the next HPhpc , namely HHVM . HHVM first PHP code into a converted intermediate bytecode format, and caches the converted bytecode JIT compiler then converts bytecode and optimize cache, it becomes x86_64 machine code. HHVM JIT compiler provides many low-level performance optimization measures, these measures is to optimize PHP code directly compiled into HPHPc the C ++ code does not have. HHVM will promptly compiled bytecode into machine code, which is interpreted language and traditions like. October 2012 about, HHVM outperform HPHPc, and still rising.

HHVM performance beyond HPHPc Shortly after, HPHPc was abandoned. Now, Facebook is the preferred PHP interpreter HHVM.

note:

  • HHVM implementation may very responsible, but in the final analysis, HHVM just substitute PHP and PHP-FPM binaries of our properties:
  • We execute PHP script using HHVM binary files on the command line, just as PHP binaries.
  • We use HHVM binary files created FastCGI servers, like PHP-FPM as a binary file.
  • HHVM native implementation of many common PHP extensions.

HVVM for me to use it?

HVVM is not for everyone. Improve performance easier manner, e.g., to reduce the number of HTTP requests and optimizing database queries are easy to implement, can significantly improve application performance, reduce the response time. If you do not use these optimization measures, consider these optimizations do first before HHVM it. Facebook's HHVM is already done after these optimization measures are still those who want to develop further accelerate application preparation. If you feel you need HHVM, you can refer to the following resources:

View HHVM compatible PHP extension

Guess you like

Origin www.cnblogs.com/ryanzheng/p/11335056.html