BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Facebook Now Uses HHVM/JIT both in Development and Production

Facebook Now Uses HHVM/JIT both in Development and Production

This item in japanese

Bookmarks

Facebook has announced using HHVM, a HipHop VM with JIT compilation, in production, a solution that has unified their development and deployment environments, providing significant performance gains for developers.

For page load performance reasons Facebook decided to implement a PHP-to-C++ tool chain which was open sourced back in 2010 under the name HipHop PHP, the compiler being called HPHPc. The tool converts PHP to an Abstract Syntax Tree (AST) then to C++ which is statically compiled to x64 binary code. While this speeded up web pages, it had an impact on development since each developer at Facebook has a complete copy of the website’s code tree and had to wait for the entire codebase to be compiled. Because the website continued to grow at a high rate, the compilation phase grew to about 10 minutes, which is a lot for a developer to wait for, according to David Mortensen, Engineering Director at Facebook, discussing HPHPc at QCon SF 2012.

To solve the problem a decision was made to keep the compiler for production code and create an interpreter (HPHPi) for development, which was supposed to eliminate the compilation dead times. The result was that the production environment became different from the development one, one of the problems being using different ASTs for performance reasons, and it turned out HPHPi was slower than the original Zend engine used before introducing HipHop, according to Drew Paroski, a FB engineer.

For this new problem they faced, a small team of Facebook engineers devised a virtual machine called HHVM (HipHop VM), and it has been used for development since 2011. After many months of JIT tuning, HHVM has been introduced in production to serve deployed code, Paroski announcing that HHVM has caught up with HPHPc and even surpassed it a bit in home page load time. This means development and deployment now use a unified environment at Facebook, with room for performance improvements as the JIT engine gets more tuned, as Paroski stated:

HHVM enables us to pursue a broader range of optimization strategies for our PHP development stack, from the runtime and base library APIs down to the bare-metal machine code we generate. We plan to leverage this flexibility to make Facebook’s web tier even more efficient in the coming years.

We’re also excited to continue improving the HipHop development experience by making our installation and development workflow easier and more flexible and by supporting a wider range of popular PHP applications and frameworks.

HipHop is a mixed environment right now, partially interpreted but the bulk of the code is JIT-compiled, according to Paroski:

HHVM runs PHP programs by converting the PHP source into HipHop bytecode (HHBC) and executing the bytecode using both a bytecode interpreter and an x64 JIT compiler that seamlessly interoperate with each other. The JIT is used where possible, and the interpreter is used as an execution engine of last resort.

Facebook has open sourced HHVM and has deprecated HPHPi and removed support for building it. They will also stop supporting HPHPc by mid-2013. There are HHVM pre-built packages for Ubuntu 12.04 and instructions for CentOS 6.3, while FreeBSD 9 and Mac OS support will follow next year after HPHPc’s retirement.

Rate this Article

Adoption
Style

BT