...
Latest News

HipHop Hurray! Facebook's New Look

Feb 9, 2010 , Posted by Lyka Adams at 3:57 AM

This article was written by: Justin Andrews for Wicked Techie

Email Wicked Techie


Wicked Techie is an online blogger who is fascinated about gadgets, computers and other technology related subjects.

[starttext]
Yep! Facebook is one of the hottest social media sites aside from Twitter, and with that in mind, it is also one of the slowest in it's niche. Because it hosted a lot of games (both browser-made and flash-made games) that I noticed to be third-party.


Facebook has come a long long way just to keep us, their loyal users and fans, happy and satisfied. Now, Facebook took another step to make it much better, faster and stronger! Yes, indeed. Like the title of the post suggest. Facebook has completely rewritten it's PHP Runtime to make it load faster and more efficient.

Facebook has been there for us to (at first) connect us with our friends and classmates. Now it is one revolutionary social network that connects almost everyone. I really mean "Connect," because some of it's awesome features like facebook's instant messenger. With respect to those who don't know where it is, you can see the messenger in the bottom-right corner of your screen (if you have your screen maximized) or your browsers (just to be clear).

- CPU Usage = Fewer Servers = - Overhead

According to the illustration above. Less CPU Usage means fewer servers, which means less overhead. With the use of HipHop for PHP, they reduced the CPU usage on their web servers on average of about 50% (fifty percent), which depends on the specific page the certain user is viewing. It had a huge impact on Facebook that one of their developers, Haiping Zhao, said at his blog that HipHop will be released as an open source, effective last Tuesday.

HipHop is described as a source code transformer where HipHop transforms your PHP source code programmatically into a highly optimized C++ code and then it is compiled using G++. More like a source code optimizer for me. With HipHop, the program executes the source code in a semantically equivalent manner and sacrifies some rarely used features.

"HipHop transforms your PHP source code into highly optimized C++ and then compiles it with g++ to build binary files. You keep coding in simpler PHP, then HipHop executes your source code in a semantically equivalent manner and sacrifices some rarely used features - such as eval() - in exchange for improved performance.

Facebook sees about a 50% reduction in CPU usage when serving equal amounts of Web traffic when compared to Apache and PHP. Facebook's API tier can serve twice the traffic using 30% less CPU"


How HipHop Works

The main challenge of the project was bridging the gap between PHP and C++. PHP is a scripting language with dynamic, weak typing. C++ is a compiled language with static typing. While PHP allows you to write magical dynamic features, most PHP is relatively straightforward. It's more likely that you see if (...) {...} else {..} than it is to see function foo($x) { include $x; }. This is where we gain in performance. Whenever possible our generated code uses static binding for functions and variables. We also use type inference to pick the most specific type possible for our variables and thus save memory.

sources: 
http://developers.facebook.com/news.php?story=358&blog=1

[endtext]

Currently have 0 comments:

Leave a Reply

Post a Comment