HipHop for PHP


Published on

Summary of HipHop for PHP

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

HipHop for PHP

  1. 1. HipHop for PHP HPHP
  2. 2. What is HPHP? • • • • • • • Haipeng’s PHP HipHop HPHPc : compiler HPHPi : interpreter for developer mode HPHPd : debugger HHVM : virtual machine HHBC : bytecode
  3. 3. Why is PHP? • Facebook application is written in 20 millions lines of PHP.
  4. 4. History 2008 • HPHPc • performanc e improvem ents (up to 6x) 2010 • opensourced • HPHPc • HPHPi • HPHPd • begin to develop HHVM 2012 • the perform ance of run ning on HH VM achieve d parity wit h HPHPc. 2013 • deprecated HPHPc. • the producti on version of facebook .com starte d running o n HHVM.
  5. 5. HPHPc • Traditional static compiler • PHP→AST→C++→x64
  6. 6. HPHPc was great • At the peak of HPHPc, PHP code showed dramatic performance improvements (up to 6x) compared to Zend PHP
  7. 7. HPHPc was great. But… • the curve for further performance improvements had flattened. • did not fully support the PHP language. • required a very different push process, requiring an over 1GB binary to be compiled and distributed to many machines in short order. • HPHPc did not support HPHPd • HPHPi was becoming slow for development. • Maintaining HPHPc and HPHPi in parallel was becoming cumbersome.
  8. 8. HHVM • HHVM uses HPHPc's PHP→AST implementation and extends the pipeline to PHP→AST→HHBC→x64 translator • 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-intime (JIT) compiler. In these respects, HHVM has similarities to virtual machines for other languages including C#/CLR and Java/JVM. • There is near full support for the entire 5.4 PHP language (including the create_function() and eval() functions). • here is one execution engine for both production and development(no need to maintain HPHPi any longer). • There is both production and development integration with HPHPd.
  9. 9. HHVM • HHVM uses a just-in-time compilation approach to achieve superior performance while maintaining the flexibility that PHP developers are accustomed to. • To date, HHVM (and its predecessor HPHPc before it) has realized over a 9x increase in web request throughput and over a 5x reduction in memory consumption for Facebook compared with the Zend PHP 5.2 engine + APC. • HHVM can be run as a standalone webserver (i.e. without the Apache webserver and the "modphp" extension). HHVM can also be used together with a FastCGI-based webserver, and work is in progress to make HHVM work smoothly with Apache.
  10. 10. Performance – HPHPc vs HHVM
  11. 11. Tracelet • try a very simple form of tracing that limits each trace to a single basic block with known input types. • simplifies the trace cache management problem, because complex application control flow cannot create a combinatorial explosion of traces. Each tracelet has a simple three-part structure: – Type guard(s) • prevent execution for incompatible input types, and the remainder of the tracelet does the real work – Body – Linkage to subsequent tracelet(s)
  12. 12. HHBC 1. f() is executed twice, for which the translator creates three tracelets. 2. f($a, 42) causes creation of tracelets A and B. 3. f($a, "hello") causes creation of tracelet C. 4. B is used by both invocations.
  13. 13. Roadmap • • • • • • • • • • Support for Apache web server. Support for php.ini and associated options. Streamlining the installation process. Support for the ARMv8 (AArch64) architecture. Ensuring HHVM passes all unit tests for the top 20-30 PHP Frameworks. Continuing adding missing functionality and extensions so that more PHP code runs. Fixing bugs. Run the top 20-30 PHP Frameworks in real world scenarios. First-class documentation around HHVM. Super easy install on as many distributions as possible.
  14. 14. Who is using HHVM(2014.01) • • • • • • • • Facebook TechKang Hyves Tuenti SIAPKu GREE Miles By Motorcycle
  15. 15. Performance Test • Hardware – CPU • Intel Xeon E312xx, 2.3GHz, 4 Cores – RAM • 4GB • Code – Executing multiple select queries to MySQL database. – Serializing selected dataset to JSON string.
  16. 16. Performance Test – Apache+MYSQL
  17. 17. Performance Test – HHVM+MYSQL