Tech Blog :: facebook


Feb 3 '10 11:38am

HipHop PHP Engine by Facebook

Facebook formally presented its HipHop project last night. (Video below.) PHP is written in C but interpreted and runtime, and trades code simplicity for performance. So HipHop aims to convert PHP into optimized C++ "just in time" (which I think is the same as runtime), then compile that C++ and run it much faster than PHP would otherwise run. They've been running it live for six months and claim it uses 50% less CPU than the standard engine with equal traffic, and 30% less CPU with twice the traffic (compared to the Zend engine with APC opcode cache).

Most of the "magical" features supported in PHP (but not in C++) were preserved, but eval(), which allows arbitrary code to be run in the script, was removed. This means Drupal can't use HipHop, for one thing.

The optimization potential depends on "how much of your code looks like C++?" Flexible variable types, for instance, run slower than type-cast variables, so HipHop has an "inference engine" to convert to C++ variable types, gaining performance for clear types but not so much when using "variant" types.

HipHop also uses its own HTTP server, so no Apache support (yet). Tabini notes, "Of course, this doesn’t preclude you from running one or more HipHop projects against separate ports on the same machine and then use Apache (or Squid, or any other server) to reverse proxy to them."

It'll all be open source, of course: the project home is here, and code will be on GitHub "soon."

Update: Four Kitchens ponders ways Drupal could be modified to support HipHop. (The changes suggested there should probably be done regardless.) I look forward to seeing that in their Pressflow distribution.