HipHop for PHP
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

HipHop for PHP

on

  • 2,808 views

Summary of HipHop for PHP

Summary of HipHop for PHP

Statistics

Views

Total Views
2,808
Views on SlideShare
2,808
Embed Views
0

Actions

Likes
0
Downloads
8
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

HipHop for PHP Presentation Transcript

  • 1. HipHop for PHP HPHP
  • 2. What is HPHP? • • • • • • • Haipeng’s PHP HipHop HPHPc : compiler HPHPi : interpreter for developer mode HPHPd : debugger HHVM : virtual machine HHBC : bytecode
  • 3. Why is PHP? • Facebook application is written in 20 millions lines of PHP.
  • 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. HPHPc • Traditional static compiler • PHP→AST→C++→x64
  • 6. HPHPc was great • At the peak of HPHPc, PHP code showed dramatic performance improvements (up to 6x) compared to Zend PHP
  • 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. 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. 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. Performance – HPHPc vs HHVM
  • 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. 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. 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. Who is using HHVM(2014.01) • • • • • • • • Facebook TechKang Hyves Tuenti SIAPKu GREE SkyFMS.com Miles By Motorcycle
  • 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. Performance Test – Apache+MYSQL
  • 17. Performance Test – HHVM+MYSQL