Facebook's HipHop Also a PHP Webserver
darthcamaro writes "As expected, Facebook today announced a new runtime for PHP, called HipHop. What wasn't expected were a few key revelations disclosed today by Facebook developer David Recordan. As it turns out, Facebook has been running HipHop for months and it now powers 90 percent of their servers — it's not a skunkworks project; it's a Live production technology. It's also not just a runtime, it's also a new webserver. 'In general, Apache is a great Web server, but when we were looking at how we get the next half percent or percent of performance, we didn't need all the features that Apache offers," Recordon said. He added, however, that he hopes an open source project will one day emerge around making HipHop work with Apache Web servers.'"
For all the trouble you're going through to convert PHP into C++ (300,000 lines and 5,000 unit tests), wouldn't programming in C++ in the first place be easier?
He said they were struggling just to get half a percent more performance with Apache. That had nothing to do with "HipHop".
In reality their CPU usage dropped average 50%
With HipHop we've reduced the CPU usage on our Web servers on average by about fifty percent, depending on the page.
the php haters: "look how awful php is, you need to convert everything into c++ before you can use it in really large scale deployments!"
"Look how awful C++ is, you have write bits in assembly to get it to really run."
"Look how awful assembly is, you really optimize when you can write machine opcodes."
And the microcode guys just glare out from their caves with their glowy little eyes in incredulity.
Elsewhere is heard, "You guys still use CPU's? It's the GPU decade, dude."
And somebody down the hall builds an ASIC to solve a specific problem and thinks he's so smart.
But, the analog EE understands his elegant circuit doesn't enable a team of 200 developers to build the top social networking site.
My God, it's Full of Source!
OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
My guess is that it was probably a progression from "Haiping's PHP" to HPHP to HipHop.
Two syllables vs four or more... looks like they're not just computing more efficiently, but also speaking more efficiently!
What makes PHP nice is that it is so close to C. For people who are comfortable working in C, PHP is just a few dollar signs away.
Check out my sci-fi/humor trilogy at PatriotsBooks.
Application servers based on Java are heavy only on start up, the allocated memory is then reused which makes it light on system load once started.
Java uses some of its memory to cache machine code in order to re-execute it the next time it is needed and this also makes it light on system load.
Simply by using top, you could understand what I am talking about. Java uses more memory but it is otherwise very light on system load and guess what ?
Machines typically have 4 GB of ram nowadays.
Most people bitching about Java being heavy do not understand what I am trying to explain to you here ;-)
Everything I write is lies, read between the lines.
Hopefully he has upgraded to the "once in a while" switch replacement technique.
That struck me as weird, because as a programmer you usually start with conditionals and then move on to loops. I had a hard time believing that someone would know of "while(true)" and not "else if".
So I decided to run some tests over dinner. I'm no C++ programmer but here's how I went with this.
First I wrote a tests.cpp that looks like this:
#include
int main () {
int subType, mainType = 11;
Slashdot_Filter_Sucks // Editable section // End of editable
while (true) {
if (mainType == 7) {
subType = 4;
break;
}
if(mainType == 9) {
subType = 6;
break;
}
if(mainType == 11) {
subType = 9;
break;
}
break;
}
Slashdot_Filter_Sucks
std :: cout
I compiled that and it resulted in a 8120 bytes binary that ran in 0.005ms.
I thought about other obvious and simple ways to write this code and I created four more versions that are identical except for the code between the dividers (I had pretty asterisk lines but Slashdot's junk filter made me take it off). They are:
testif.cpp (test using an if/else statement):
if (mainType == 7) subType = 4;
else if (mainType == 9) subType = 6;
else if (mainType == 11) subType = 9;
testifonly.cpp (no else, only ifs):
if (mainType == 7) subType = 4;
if (mainType == 9) subType = 6;
if (mainType == 11) subType = 9;
testswitch.cpp (using a switch statement):
switch(mainType) {
case 7: subType = 4;
case 9: subType = 6;
case 11: subType = 9;
}
testp.cpp (subtract 3 from mainType since that seemed like a pattern):
subType = mainType - 3;
I compiled everything using g++ then I ran time ./output. All the versions ran on average in 0.005ms, however, the binary sizes were different:
#ls -l (ordered by size)
8072 testp
8109 testifonly
8120 tests
8121 testif
8125 testswitch
Ok, no case here in terms of size. So I tried compiling again with -O3, and the results were:
#ls -l (ordered by size)
8024 testp_o3
8024 tests_o3
8025 testif_o3
8029 testifonly_o3
8029 testswitch_o3
Here it seems that the subtraction and the weird while/break method have the smallest file size. Without code context, one can imagine that subType was to be left alone if mainType was not 7,9 or 11. Which would mean the subtraction code wouldn't work in that scenario.
Now, I don't know the intricacies of C++ or Assembly, but I have to wonder if this was the work of a moron or someone who knew exactly what they were doing and did so for a reason.
Again, without context, none of this matters.
If you can't mod them join them.