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.
What with their stupid success and their stock options growing in value. Man, what a bunch of fucking retards.
I scream. You scream. I assume that means we're both acquainted with the problem. We proceed.
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.
Well, JavaScript is even closer, then - not even dollar signs needed.
In truth, however, it may be a curse rather than a blessing. The syntax looks deceptingly familiar, but semantics are anything but. C is a language where things are generally unambiguous and straightforward, even when syntax is cryptic. PHP is the opposite - seemingly simple syntax can have a lot of subtle ambiguities. See my other comment to this story for an example.
Yeah I think I'm going to go buy stock in companies because they use PHP. Take that! hurrrr
Please, Slashdot Gods, give me a preference filter to hide all comments which begin with "Meh".
If you mod me down, I shall become more powerful than you could possibly imagine.
Mainly because I have a fundamental difference of opinion when it comes to return values versus exceptions. The Java folks seem to prefer the latter quite frequently. I tend to think that exceptions are for things that are truly exceptional---the equivalent to a kernel panic---something that should almost always cause the program to crash or at most, clean up and die. Thus, exceptions should never be thrown by any standard library because no library can reasonably determine what is or is not fatal to the application that calls it.
And even within application code itself, exceptions are really just a crutch so that programmers can be lazy and skip error checking throughout large blocks of their code. The result, at least in my experience, tends to be pretty much what you would expect---buggy code that crashes or misbehaves with regularity. That's not saying you can't write good code in Java, just that in my experience, that's the exception rather than the rule. No pun intended. Exceptions save a little bit of time during the coding phase, but they make it much harder to debug certain classes of problems. They're basically the Java equivalent of setjmp or GOTO---well, not quite that bad, but close.
I know, $10 answer to a fifty cent question, but....
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.
I write in PHP, among lots of other languages. I'm not a hater. I'm also interested in this project for renting out space to PHP-based projects. Higher density per server = less costs :)
But where's the code? My calendar says "Wednesday", and I was sure this was a Tuesday announcement. Github search turns up nothing. How long does it take to upload 300k lines of code? Getting impatient here ;)