Facebook's HipHop 2.0 Virtual Machine Is Very Fast

Written by Michael Larabel in Free Software on 9 April 2013 at 04:51 AM EDT. 18 Comments
FREE SOFTWARE
Released last month by Facebook was their open-source HipHOp "HHVM" 2.0 virtual machine. Benchmarks of HHVM at Phoronix show that the code does live up to Facebook's performance claims.

For several years now Facebook has been experimenting with making PHP faster through various techniques. Facebook heavily relies upon the PHP server-side scripting language and for handling their immense traffic, they need PHP to be as fast as possible.

The original HipHop (HPHPc) transformed PHP source-code into C++ that was then passed into GCC for producing a native, system binary. Eventually, work turned to HipHop's HHVM, which is a virtual machine that compiles PHP source code into a Bytecode that is then run on a virtual machine or compiled to system code using a custom JIT compiler. HHVM is the technique Facebook currently uses for their site and is now their primary focus of HipHop.

With the HipHop 2.0 PHP release from last month, they killed off the older HPHPc compiler and are focusing on just HHVM. Released later on in March was HipHop 2.0.1 with bug-fixes.

For anyone interested in more details on Facebook's HipHop/HHVM see their GitHub Wiki page.

With the upcoming release of PHP 5.5, yesterday I delivered performance benchmarks of PHP 5.5 when compared to the older PHP 5.4, 5.3, and 5.2 stable branches. Using the same test case (phoronix-test-suite debug-self-test; see the aforelinked article for more test details), I checked to see how HipHop 2.0.1 performed from the Apple MacBook Pro with Intel Core i5 CPU running Ubuntu 12.04.2 LTS.

The same system hardware and software running the same test and the same code was pushed through Facebook's HipHop 2.0.1 HHVM. The results are outright impressive:
PHP 5.3.3.hiphop
DETAILED_SYSTEM_INFO:          0.121 seconds
LIST_AVAILABLE_TESTS:          0.348 seconds
LIST_AVAILABLE_SUITES:         42.185 seconds
INFO:                          0.029 seconds
CLONE_OPENBENCHMARKING_RESULT: 30.419 seconds
RESULT_FILE_TO_TEXT:           0.009 seconds
DIAGNOSTICS:                   0.005 seconds
DUMP_POSSIBLE_OPTIONS:         0.004 seconds

ELAPSED TIME:                  219.362 seconds
PEAK MEMORY USAGE:             0.871 MB
PEAK MEMORY USAGE (emalloc):   4 MB

The total test time was now just 219 seconds compared to the 509 seconds needed for PHP 5.4 or 540 seconds for the upcoming PHP 5.5 release. Using HHVM rather than upstream PHP was significantly faster for this very real-world workload, which is made up of PHP objects, file I/O, zip/tar.gz file compression, PHP string functions, and other common core PHP calls.

The most user-facing area where Facebook's PHP engine was significantly faster was with the clone-openbenchmarking-result sub-command, which is largely made-up of calls to pts_Graph, the Phoronix Test Suite PHP library for rendering SVG graph files. The graph rendering is computationally complex and does use the PHP DOM (Document Object Model) along with other common PHP string functions.

In terms of the peak memory usage, the HHVM numbers were very low, but it seems likely that HHVM isn't implementing the memory_get_peak_usage() function, so it's simply the times for what's being looked at here.

Overall, the performance of HipHop HHVM is very impressive compared to PHP 5.5/5.4/5.3/5.2. In my internal tests I have also found that HHVM is also much faster on another one of my unreleased code-bases.

In terms of pushing code through HHVM compared to upstream PHP, it's quite comparable to PHP 5.3 support. When initially "porting" the Phoronix Test Suite to handle running on HHVM, there were just a few differences mostly coming down to HHVM having some semantic PHP CURL differences for file downloading, adding comments to a PHP DOM object yields differences between PHP and HHVM, and HHVM has no plans to implement the get_defined_constants() call.

Those are the only issues I recall, which were easily worked around within the Phoronix Test Suite Git code-base. The other code-base I tested against HHVM had no problems at all compared to where it normally runs on PHP 5.3.

Overall, Facebook's HipHop HHVM has been working very nicely throughout my internal testing and evaluation.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week