HipHop for PHP

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Stylized white 'h' character on a blue background with a darker blue border on the character's edges.
Developer(s) Facebook
Initial release February 2, 2010; 4 years ago (2010-02-02)
Stable release 3.0.1[1] / April 4, 2014; 3 months ago (2014-04-04)
Development status Active
Written in C++, C, PHP
License Free software (PHP License)
As of May 2013

HipHop for PHP (shortened as HipHop) describes a series of PHP execution engines and improvements created by Facebook. The original motivation of HipHop was to save resources on Facebook servers, given the large PHP codebase of As development of HipHop progressed, it was realised that HipHop could substantially increase the speed of PHP applications in general. Increases in web page generation throughput by factors of up to 6 have been observed over Zend PHP.[2][3][4][5][6] A stated goal of HipHop is to provide a high level of compatibility for Zend PHP, where most Zend-based PHP programs run unmodified on HipHop.[4] HipHop was originally open-sourced in early 2010.[7]

The current version of HipHop, known as HHVM (HipHop Virtual Machine) was open-sourced in late 2011.[8]

HipHop consists mainly of C++, C and PHP source code and is free and open-source software distributed under the PHP License. Project's source code is hosted on GitHub.

History before HHVM[edit]

HipHop (known as HPHP) is an execution engine for PHP. Beginning in 2008, Facebook engineers began working on HPHP. The original release of HPHP was as a PHP to C++ compiler, known as HPHPc. PHP code was written and, when run through HPHPc, was transformed into C++, compiled into a binary and run as an executable (as opposed to being compiled to opcodes and interpreted). At the peak of HPHPc, PHP code showed dramatic performance improvements (up to 6×) compared to Zend PHP.[2][3][4]

As an adjunct to HPHPc, Facebook engineers also created a "developer mode" of HipHop (known as HPHPi) and the HipHop debugger (known as HPHPd). This allowed developers to run PHP code through the same logic provided by HPHPc while, at the same time, allowing them to interactively debug PHP code. Developers could set watches, breakpoints, etc. Of course, the code run through HPHPi was not as performant as the code run through HPHPc, but the developer benefits were, at the time, worth having to maintain these two execution engines for production and development. HPHPc, HPHPi and HPHPd were all open-sourced in 2010.[7]

By many accounts, HPHPc was a huge success, especially within Facebook as it allowed to run much faster, using less resources. However, in early 2013, Facebook deprecated HPHPc.[9] There were many reasons for this. For all the performance gains that HPHPc provided, the curve for further performance improvements had flattened. HPHPc did not fully support the PHP language, including the create_function() and eval() constructs. HPHPc required a very different push process, requiring a bigger than 1 GB binary to be compiled and distributed to many machines in short order. HPHPc did not support HPHPd, and, given the amount of lines of code that made up, HPHPi was becoming slow for development. Plus, maintaining HPHPc and HPHPi in parallel (as they needed to be for production and development consistency) was becoming cumbersome. Finally, it was not a drop-in replacement for Zend as external customers would have to change their whole development and build process to use HPHPc.

HipHop Virtual Machine (HHVM)[edit]

To solve the issues brought about by HPHPc, Facebook decided to create a PHP virtual machine. Foreseeing the possible issues arising with HPHPc, development on the HipHop virtual machine (known as the HHVM) began in early 2010. HHVM builds on top of HPHPc, using the same runtime and extension function implementations. HHVM converts PHP code into a high-level bytecode (commonly known as an intermediate language). This bytecode is then translated into x64 machine code dynamically at runtime by a just-in-time (JIT) compiler. In these respects, HHVM has similarities to virtual machines for other languages including C#/CLR and Java/JVM.

Facebook also released Hack, a programming language for HHVM that can be seen as a new version of PHP; it allows programmers to use both dynamic typing and static typing.[10] An open-source version of Hack is part of the HHVM runtime platform.[11]

HHVM brings with it many benefits over HPHPc. There is near full support for the entire 5.4 PHP language (including the create_function() and eval() functions).[12][13] There is one execution engine for both production and development (i.e., no need to maintain HPHPi any longer). There is both production and development integration with HPHPd. And the push process becomes much simpler; no more lengthy binary build time that existed with HPHPc.

However, the key question is around performance. As a virtual machine, HHVM has the ability to use live type information to produce more efficient native code, leading to higher webserver throughput and lower latency. In Q4 2012, the performance of running on HHVM achieved parity with HPHPc,[14] while in December 2013 it was even surpassed by around 15%.[15] In Q1 2013, the production version of started running on HHVM, replacing HPHPc.

See also[edit]


  1. ^ facebook (2014-04-04). "Releases - facebook/hhvm". Retrieved 2014-05-24. 
  2. ^ a b "OOPSLA '12 Paper". Retrieved 2013-05-23. 
  3. ^ a b "QCon 2012 HipHop Compiler Presentation". Retrieved 2013-05-23. 
  4. ^ a b c "FOSDEM 2013 Interview". Retrieved 2013-05-23. 
  5. ^ "HipHop for PHP: Benchmark". Retrieved 2013-05-23. 
  6. ^ "Drupal 7: HipHop for PHP vs APC – benchmark". Retrieved 2013-05-23. 
  7. ^ a b "HipHop For PHP - Move Fast". Retrieved 2013-05-23. 
  8. ^ "The HipHop Virtual Machine". Retrieved 2013-05-23. 
  9. ^ "Announcement on GitHub removing HPHPc support". Retrieved 2013-05-24. 
  10. ^ "Hack: a new programming language for HHVM". Retrieved 2014-03-20. 
  11. ^ "GitHub - facebook / hhvm". Retrieved 2014-03-20. 
  12. ^ "GitHub issue discussion about PHP 5.4". Retrieved 2013-05-24. 
  13. ^ "Zend compatibility tests hosted on GitHub". Retrieved 2013-05-24. 
  14. ^ "State of HHVM in late 2012". Retrieved 2013-05-24. 
  15. ^ "We are the 98.5% (and the 16%) « HipHop Virtual Machine". December 2013. Retrieved 2014-02-23. 

External links[edit]