More Details On The HHVM Virtual Machine Design
After earlier this week delivering benchmarks showing Facebook's HipHop 2.0 Virtual Machine is very fast, a Facebook engineer commented in our forums about some of the design choices that were made.
Facebook's HHVM should have no problem outperforming PHP 5.5 as shown with our benchmarks. In response to the article earlier this week, there was some surprise along with questions raised. Facebook's Drew Paroski who has worked on their high-performance implementation of PHP commented to elaborate on some of their motives and positions for doing this work.
- Back in 2007~2008 they contributed patches back to Zend PHP 5.2 that yielded 5~10% reduction in CPU usage, as tested on Facebook's code-base. It was also around that time they began exploring other PHP engines and prototyping their HiHop compiler of taking PHP and converting it to C++.
- While HipHop is open-source, in terms of why they haven't tried contributing it back upstream: "After a certain point it became hard to get more gains from the Zend engine unless we substantially changed the core of the engine, and by early to mid 2009 HPHPc was getting close to being able to run Facebook's site and was looking promising."
- Paroski also added about their open-source position with HipHop, "we *are* giving back to the PHP community by open-sourcing HipHop VM, making it freely available to use, and having some engineers dedicated full-time to responding to issues reported by developers outside of Facebook. We're dedicated to maintaining a high compatibility bar with the Zend PHP engine; we want HipHop VM to be useful to developers outside of Facebook and we're slowing growing a community around it."
- If you're wondering why they used their own bytecode and virtual machine instead of the widely-used industry-leading LLVM, it simply wasn't in the state it is today back when they began work on their JIT compiler in 2010. When they began, LLVM's Just-In-Time compilation abilities weren't good enough for Facebook. Facebook engineers also found value in "owning" their entire compiler stack with greater flexibility to max out its performance for the PHP code-base.
- The HipHop developers plan to fully support the PHP 5.4 language as well as to support more PHP extensions. They also want to make it easier for outside developers to port existing and new extensions to HipHop VM.
- In terms of the current PHP 5.4 support: "we support most PHP 5.4 language features, including eval, traits, exceptions, late static binding, closures, magic methods (__get, __set, etc.), typehints, autoload, nowdocs, etc. Off the top of my head, the main features missing at present are namespaces and short array syntax, which we plan to add in the coming months. Also, there was some missing functionality with closures, but we've recently fixed that and the fixes should make it to our open-source github repo soon...HipHop currently supports a few dozen of the popular Zend extensions, but there are still several popular Zend extensions that haven't been ported to HipHop yet. While we plan to port a few more extensions this year, we're focusing primarily on making it easier to add/port extensions to HHVM. This includes cleaning up HipHop's extension system to be more friendly, having good documentation, and possibly writing some tools to help port existing Zend extensions."
For those wanting to find out more details or to checkout Facebook's source code for this high-performance PHP implementation, visit their GitHub page.
Latest Articles & Reviews
Latest Linux News
Most Viewed News This Week