Slashdot Mirror


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.'"

4 of 304 comments (clear)

  1. GUI applications by sopssa · · Score: 5, Interesting

    While theres already several libraries intended for creating windows and interfaces with PHP, and to put them together into an executable file, this might greatly improve that area in PHP too. While being faster as well, being machine code it protects your code too.

    Along with making it work with Apache Web servers I hope someone works on this aspect too. PHP is really nice and fast to write. *ducks from the c/c++ coders*

    Definitely interesting project.

    1. Re:GUI applications by MightyMartian · · Score: 5, Funny

      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.

      Which is like saying an anus is almost like a vagina...

      Feel free to take that analogy the distance.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    2. Re:GUI applications by eihab · · Score: 5, Insightful

      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
          while (true) {
              if (mainType == 7) {
                  subType = 4;
                  break;
              }
              if(mainType == 9) {
                  subType = 6;
                  break;
              }
              if(mainType == 11) {
                  subType = 9;
                  break;
              }
              break;
          }
          Slashdot_Filter_Sucks // End of editable

          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.
  2. Well, I Guess "HipHop" Is the New Champ! by RobotRunAmok · · Score: 5, Funny

    And here I never thought that anything could ever take the award for "Most Stupidly Named Software" away from the Ubuntu distros.

    Congrats again, HipHop! Can I get a Fist-Bump?!