News on Monday
more>>
SharePoint Tech Report
more>>


   

 
 
Download Current Issue
ISSUE 3/15/2010 PDF

Need Back Issues?
DOWNLOAD HERE

Receive the print Edition?


 
blogs tab
ASP.NET MVC 2 Ships
ASP.NET MVC 2 has shipped.
03/12/2010 10:26 AM EST

Microsoft plans 'open' Silverlight analytics framework
Microsoft is going to announce a multipurpose analytics framework for Silverlight at MIX.
03/11/2010 09:51 AM EST

About CSS processing
Two sites that lead to a startling CSS conclusion.
03/10/2010 02:29 AM EST

 

Events calendar tab
3/14/2010 to 3/18/2010
Seattle, Wa.
SHARE

3/15/2010 to 3/18/2010
Santa Clara, Calif.
TechWeb

3/15/2010 to 3/17/2010
Las Vegas
Microsoft

3/16/2010 to 3/19/2010
Las Vegas
Penton Media

3/17/2010 to 3/19/2010
Las Vegas
TechTarget


 
Most Read Latest News Blog Resources

Facebook brings HipHop to PHP




February 2, 2010 — 
Facebook today released HipHop for PHP, a source code transformer that changes PHP into highly optimized C++, which is then compiled with G++.

The company confirmed that it has been working on the project for two years, and that it is designed to speed up execution of the code that underlies around 80% of the Facebook codebase. This is not the first time Facebook has spent development money on PHP acceleration technology.

HipHop for PHP is part of a larger effort at Facebook to speed up its PHP infrastructure. The company has already produced lex-pass, a tool written in Haskell that helps developers to refactor their PHP code.

Facebook is also responsible for PHPEmbed, another open-source tool that improves upon the PHP APIs for embedding chunks of code written in the language into other applications. Facebook has also written PHPSH, a shell for interfacing with PHP in a manner similar to Python.

Facebook developer Haiping Zhao posted on the Facebook developers blog detailing the specifics on HipHop for PHP, such as its genesis.

“One night at a Hackathon a few years ago, I started my first piece of code transforming PHP into C++,” wrote Zhao. “The languages are fairly similar syntactically, and C++ drastically outperforms PHP when it comes to both CPU and memory usage. Even PHP itself is written in C. We knew that it was impossible to successfully rewrite an entire codebase of this size by hand, but wondered what would happen if we built a system to do it programmatically.”

Perhaps the most interesting thing about HipHop for PHP is the fact that Facebook has been using it already in production for some time. Zhao wrote that “with HipHop, we've reduced the CPU usage on our Web servers on average by about 50%, depending on the page. Less CPU means fewer servers, which means less overhead.

"This project has had a tremendous impact on Facebook. We feel the Web at large can benefit from HipHop, so we are releasing it as open source this evening in hope that it brings a new focus toward scaling large complex websites with PHP. While HipHop has shown us incredible results, it's certainly not complete, and you should be comfortable with beta software before trying it out."

So why did Facebook choose to undertake such a large and complex problem, rather than use existing PHP accelerators? As Zhao explained on his blog: “Finding new ways to improve PHP performance isn't a new concept. At runtime, the Zend Engine turns your PHP source into opcodes, which are then run through the Zend Virtual Machine.

"Open-source projects such as APC and eAccelerator cache this output and are used by the majority of PHP-powered websites. There's also Zend Server, a commercial product that makes PHP faster via opcode optimization and caching.

"Instead, we were thinking about transforming PHP source directly into C++, which can then be turned into native machine code. Even compiling PHP isn't a new idea; open-source projects like Roadsend and phc compile PHP to C; Quercus compiles PHP to Java; and Phalanger compiles PHP to .NET,” wrote Zhao.

Paul Biggar is maintainer of PHC, an open-source PHP compiler. He's worked on that project since 2005, and he expressed surprise on his blog at the sudden interest in compiled PHP. He pointed out that his own compiler project, along with other PHP compiler projects, have been somewhat stagnant in recent years. He said that he has tried repeatedly to find someone to take over PHC and has failed to do so.

That being said, Biggar wrote in his blog that HipHop will still be a useful tool. “People seem to want to know if HPHP [HipHop] is widely useful outside of Facebook, and some people are saying 'no.' I disagree strongly," he wrote.

"In order for HPHP to be useful, you need to have a PHP application that is suffering due to PHP interpreter performance. That matches Facebook perfectly, and they’ve always been the canonical example I use to explain why PHP compilers are interesting. But you don’t have to be Facebook-size or scale to have performance problems."


Related Search Term(s): FacebookPHP


Share this link: http://www.sdtimes.com/link/34108
 

Comments

02/03/2010 03:24:37 PM EST

HipHop seems really interesting, at Systrix (www.systrix.com) we have had to switch to lighttpd and xcache to achieve huge performance benefits for our objectCMS framework which is now faster that wordpress, joomla and drupal. I am wondering how hiphop compares to lighttpd and xCache, does anyone know when hiphop is going to be released to the public.

United StatesKarim Dahmani


02/08/2010 08:46:02 AM EST

"This project has had a tremendous impact on Facebook....." Yeah, Facebook is now slower that ever and the user experience has gone from bad to ridiculas over the past few months. Before Facebook start's developing sidelines to there main business, why don't they make the Facebook site work properly first???

United KingdomMeee


02/08/2010 09:29:53 AM EST

Hmm, does this explain why Facebook seems to be getting slower and slower and more and more buggy?

United StatesPete


02/08/2010 11:01:20 AM EST

There is a fundamental law of optimization that appears to be consistently overlooked. If you do whatever it is you are doing faster, the best you can hope for is a small performance boost. In order to get large improvements in performance, you must figure out what you are doing that you don't NEED to do, and then quit doing it. This is platform and language independent. In fact, this law of optimization applies to other fields as well, including such diverse applications as politics, finance, and interpersonal relationships.

United Statestxchlinstructor


02/08/2010 12:56:28 PM EST

@Meee Um, this is obviously a project intended to make Facebook's site run faster, not a sideline. Did you not read the article?

United StatesDvW


Add comment


Name*
Email*  
Country     


  • Comment
  • Preview
Loading