Jump to content

HipHop for PHP

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Dsimic (talk | contribs) at 04:51, 17 July 2014 (Undid revision 617240924 by 66.66.246.77 (talk) Sorry, not an improvement). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
HipHop
Developer(s)Facebook
Initial releaseFebruary 2, 2010; 15 years ago (2010-02-02)
Stable release
3.0.1[1] / April 4, 2014; 11 years ago (2014-04-04)
Repository
Written inC++, C, PHP
LicenseFree software (PHP License)
Websitegithub.com/facebook/hhvm
facebook.com/hphp
www.hhvm.com
As ofMay 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 facebook.com. 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

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 facebook.com 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 facebook.com, 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)

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 facebook.com 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 facebook.com started running on HHVM, replacing HPHPc.

See also

References

  1. ^ facebook (2014-04-04). "Releases - facebook/hhvm". Github.com. Retrieved 2014-05-24. {{cite web}}: |author= has generic name (help)
  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". Hhvm.com. December 2013. Retrieved 2014-02-23.