Skip to content
Paul Tarjan edited this page May 15, 2013 · 131 revisions

HipHop VM (HHVM) is a new open-source virtual machine designed for executing programs written in PHP. HHVM uses a just-in-time compilation approach to achieve superior performance while maintaining the flexibility that PHP developers are accustomed to. HipHop VM (and before it HPHPc) has realized > 5x increase in throughput for Facebook compared with Zend PHP 5.2.

For the latest news about HipHop VM, find us on Facebook and check out our WordPress blog.

Why HipHop VM (HHVM)

One of the explicit design goals leading into HipHop VM was the ability to continue writing complex logic directly within PHP. Companies with large PHP codebases will generally rewrite their complex functionality directly as PHP extensions in either C or C++. Doing so ends up reducing the number of people who are able to work on the company’s entire codebase. By keeping this logic in PHP, Facebook is able to move fast and maintain a high number of engineers who are able to work across the entire codebase.

Installing pre-built packages for HHVM

Prebuilt packages for some distributions are available as shown below:

Building HHVM

HipHop is currently under heavy development and at present we only actively test on the Ubuntu distribution. Building procedures should be fairly similar on other linux distros, and support for FreeBSD and Mac OS X will be coming shortly after the retirement of HPHPc.

Here are some guides for how to get HipHop VM up and running on your distro:

Discussion and support

You can discuss HipHop for PHP and report bugs on our Facebook page, submit a ticket or Pull Request here on github, or check out the HipHop for PHP Blog. Note that the old Google Group HipHop developer mailing list is no longer active.

HHVM versus older HipHop execution engines

HipHop has evolved over the years. Initially it took the form of what we call “HPHPc”, which translates PHP to C++ code, then passes that to gcc to compile into one monolithic binary representing a site’s entire code tree. This worked well, giving significant performance gains, but it was awkward for deployment, and downright untenable for iterative development. After all, you use PHP in part to avoid having to recompile after every little change. Note also, that because of the need to pass through gcc, dynamic features such as eval() were simply dropped from the language.

An AST-based interpreter called “HPHPi” came shortly thereafter as an “interactive” version of HPHP. This provided much of the automatic-recompile-on-change behavior web developers expect, but it required a lot of effort to maintain another execution engine and to keep HPHPc and HPHPi consistent with each other.

HHVM was created with the intent to replace both HPHPi and HPHPc. Unlike its predecessors, HHVM does not call out to gcc (or libgcc) to build transformed source code. Instead, HHVM operates more similarly to regular PHP in that it compiles PHP scripts into bytecode (semantic representations of individual instructions) and executes those in a virtual machine environment.

Of course, if it stopped there, then HHVM would be only slightly more performant than normal PHP (due to its optimizer). Fortunately, it doesn’t. When running in production mode, there are a number of additional options which can be enabled to perform Just in Time (JIT) compilation on that bytecode turning it into native machine code.

Using this approach, a single compiler/execution engine (HHVM) can perform the high-performance work of a production engine (HPHPc) while still maintaining the flexibility of a development engine (HPHPi).

Support for HPHPc and HPHPi has been removed.

The wiki content is licensed under Creative Commons Attribution-ShareAlike License

Clone this wiki locally