• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Facebook makes PHP 9x faster via virtual machine (HHVM?)


Well-known member
From http://www.pcworld.com/article/2045353/facebook-invents-a-php-virtual-machine.html
HHVM is the next step for Facebook. Under development for about three years, HHVM actually works on the same principle as the Java Virtual Machine (JVM). HHVM has a just-in-time (JIT) compiler that converts the human readable source code into machine-readable byte code when it is needed. (The previous HipHop, renamed HPHPc, has now been retired within Facebook.)

This JIT approach allows the virtual machine to "make smarter decisions at runtime," said Joel Pobar, a Facebook engineering manager. . For instance, if a call is made to the MySQL database to read a row of data, the HHVM can, on the fly, figure out what type of data it is, such as an integer or a string. It then can generate or call code on the fly that would be best suited for handling this particular type of data.

With the old HipHop, "the best it can do is analyze the entire Facebook codebase, reason about it and then specialize code based on its reasoning. But it can't get all of the reasoning right. There are parts of the code base that you can not simply infer about or reason about," Pobar said.

Virtual system speedier
Pobar estimated that HHVM is about twice as fast as HPHPc was, and about nine times as fast as running straight PHP.

Facebook has posted the code for HHVM on GitHub, with the hopes that others will use it to speed their PHP websites as well.

HHVM is optimized for handling very large, and heavily used, PHP codebases. Pobar reckoned that using HHVM for standard sized websites, such as one hosting a Wordpress blog, would gain only about a fivefold performance improvement.

"If you take some PHP and run it in on HipHop, the CPU execution time [may] not be the limiting factor for performance. Chances are [the system is] spending too much time talking to the database or spending too time talking to [the] memcache" caching layer, Pobar said
I wonder if this could work for xenforo, @Mike ? The templating system makes me think that it might not have much of an effect, but I could be wrong. Thoughts?

Stuart Wright

Well-known member
Thanks Rob. I don't understand what this is or what it means, so I have sent a link to Tim @ Nimbus.
(My expertise ends at the outside of the server room door).


Well-known member
@DRE I think it will be miles quicker but you will need to go some to make xF and HHVM play ball together. Let us know how you get on though :)


Well-known member


Well-known member
XenForo itself doesn't use namespaces at this time. There are a select few add-on developers that use them (and effectively up the minimum required PHP version).