UPDATED 17:27 EDT / JULY 30 2013

NEWS

Facebook Accelerates PHP Programming Nine Times Faster Thanks to HipHop VM

To get dynamic pages faster on the screen, Facebook has put the PHP scripting language on the workbench for upgrades and the result has been a virtual machine. With an active audience of 1.1 billion people, Facebook is extremely interested in increasing the performance of web applications. Because many programmers are familiar with PHP, the company has decided not to give up this slow language, and try to fully optimize it.

PHP is a common open source server-side scripting language, which was developed for web applications, but it is also used as a general programming language and is now installed on more than 244 million sites and 2.1 million web servers.

Facebook has reached a new milestone in the treatment of PHP as a web programming language. The social network has developed a PHP Virtual Machine that it says can execute the language up to nine times faster than when running PHP natively on large systems. Facebook called the virtual machine as HHVM (HipHop Virtual Machine) and has been using it across all of its servers since earlier this year.

“Our goal is to make PHP run really, really quickly,” said Joel Pobar, a Facebook engineering manager.

HHVM is not the first attempt by Facebook to expedite the processing of PHP. In 2010, they presented HipHop (HPHPc) compiler, which translates PHP into C ++, sacrificing some commonly used PHP functions such as eval() resulting in a large increase in productivity.

Improving the JIT

HHVM uses a virtual machine environment and JIT-compiler for PHP. Unlike C or C++, traditional PHP is an interpreted language, which means the source code is executed by the processor directly. Programs written in C or C++ have been compiled beforehand into machine language byte code so that it runs quickly.

To keep up a speed like C or C++, Facebook invented a Just in Time (JIT) compiler, called HipHop, that would translate PHP code into C++, so it then it could be compiled ahead of time for faster performance. HHVM works similar to JVM (Java Virtual Machine).

The JIT approach allows the virtual machine to make smarter decisions at runtime. The JIT compiler converts the code into machine instructions, taking into account various factors: for example, if there is an address to the MySQL database, the compiler takes into account the type the data and generates the appropriate machine code.

“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 cannot simply infer about or reason about,” Pobar said.

He believes that HHVM virtual machine is about two times faster than the HPHPc and about nine times faster than PHP runs natively. For several years, the social network has drawn considerable performance gains from the use of this first version of HipHop, and Facebook sought other means to accelerate the delivery of dynamic web pages for billion users.

Facebook released the code of HHVM repository to Github repository hoping that others will also use PHP to accelerate their web sites.

HHVM the virtual machine is optimized to handle very large amounts of PHP code base 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.


A message from John Furrier, co-founder of SiliconANGLE:

Your vote of support is important to us and it helps us keep the content FREE.

One click below supports our mission to provide free, deep, and relevant content.  

Join our community on YouTube

Join the community that includes more than 15,000 #CubeAlumni experts, including Amazon.com CEO Andy Jassy, Dell Technologies founder and CEO Michael Dell, Intel CEO Pat Gelsinger, and many more luminaries and experts.

“TheCUBE is an important partner to the industry. You guys really are a part of our events and we really appreciate you coming and I know people appreciate the content you create as well” – Andy Jassy

THANK YOU