Faster PHP fo shizzle—HipHop for PHP

[ATTIC: Please ignore]

The skinny

shoutout to me. I’ve been saying for years.

And where its speed is concerned, practically everyone seems to agree that PHP is slow

http://www.fiercecio.com/techwatch/story/facebook-working-improve-php/2010-02-02?utm_medium=nl&utm_source=internal

It’s not a JIT

According to our sources, Facebook has been working on a PHP compiler that will
increase speed by around 80% and offer a just-in-time (JIT) compilation engine that will offer a number of advantages
ReadWriteWeb

JITs are notoriously hard to write. What a JIT is.

HipHop is not a JIT

HipHop builds it’s own server. No Apache.
No support of Windows (currently).

Things that don’t work in HipHop

Runtime questions

http://blog.echolibre.com/2010/02/hiphop-for-php-facebook-unveils-its-magic/
– issue with buffer overflows
– security implications
– how it cometes with phi or roadsent php

Developer questions

Joe Stumps issues about code dump

The hype around this announcement seems over the top. HipHop isn’t going to be used by people looking to speed up something like a WordPress blog. It is going to be a last resort for those who don’t want to give up PHP for some reason.

@Patrick WordPress uses eval all over the place (you can probably pick any other random PHP project and find it used) so it won’t work
Carson McDonald.

@Carson WordPress does not use eval() all over the place. It does use a little eval() here and there. For instance:

HTMLpurifier library uses it for testing code (probably never executed by WordPress)
Smarty uses it (but Smarty dynamically generates PHP code, another no-no. Solution is not to use Smarty.)
The Atom API uses it to evaluate dates. (That’s a bug that probably should be fixed.)
A lot of plugins use it (Those can be coded around and updated.)

But the thing is most people deploying WordPress on a self-hosted are not going to have the capabilities of compiling and deploying their own web-server. HipHop is a project that rewards a large scale site with a large server/power footprint. The point it does is when the developer allocation of that is small relative to the size of the footprint and the benchmark is how much it costs to plan out half of your PHP servers. For most sites, that is minimal since they’re bottlenecked on MySQL, not the webserver (as Rasmus alludes to)

It certainly isn’t a “last resort” IMO. You (and others) make it sound like PHP is inherently slow. It is compared to C, but it’s actually comparable in speed to Python and Perl and faster than Ruby. Scripting development has always been about trading off

With HipHop, Facebook Gives PHP a Turbo Charge


PHP is interpreted on the fly
PHP is not interpreted on the fly (or not unusually so)

X Picture of Andrei
X Picture of Ben Ramsey
X Picture of Chris Jones: http://blogs.oracle.com/opal/2010/02/facebooks_hphp_initial_comment.html
X Picture of Pat Reilly
X Picture of Lion
X Picture of Me
– Picture of Scott
– Picture of Haiping speaking
X Picture of another engineer at FB
– Picture of FB PM
– Picture of Schwag
X Random pictures of facebook
– facebook dinner stuff

Links to read and reference:
http://www.internetnews.com/dev-news/article.php/3862506
http://technosailor.com/2010/02/04/hiphop-php-and-the-evolution-of-language/
http://developers.facebook.com/news.php?blog=1&story=358
http://www.allfacebook.com/2010/02/facebook-formerly-announces-hiphop-for-php/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+allfacebook+%28Facebook+Blog%29
http://ilia.ws/archives/213-My-Thoughts-on-HipHop.html

HipHop For PHP: Who Benefits, Who Doesn’t

With HipHop, Facebook Gives PHP a Turbo Charge


http://blogs.zdnet.com/BTL/?p=30331
http://arstechnica.com/open-source/news/2009/03/google-launches-project-to-boost-python-performance-by-5x.ars
http://www.techcrunch.com/2010/02/02/facebook-hiphop-presentation/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Techcrunch+%28TechCrunch%29
http://blogs.oracle.com/opal/2010/02/facebooks_hphp_initial_comment.html
http://blog.echolibre.com/2010/02/hiphop-for-php-facebook-unveils-its-magic/
http://www.websdeveloper.com/community-news-responses-to-the-facebook-hiphop-announcement/
http://blog.roshambo.org/archives/PHPVille-almost-released-today.html

HipHop For PHP: Who Benefits, Who Doesn’t


http://withoutscope.com/2010/2/3/hiphop-for-php-is-not-php?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+without_scope+%28without_scope%29

Opiniones sobre HipHop de Facebook


http://www.landoweb.com/2010/02/04/hiphop-your-way-to-php/

What Facebook's HipHop means for developers and businesses

61 thoughts on “Faster PHP fo shizzle—HipHop for PHP

    1. My blog post isn’t finished but I haven’t claimed “only if you’re big.” (yet). My claim is that you need over 2 machines and a bottleneck in the application server (which is rare).

      To your point specifically, Harry, you are correct. If your latency gets degreased than this is good. But taking a real world example, before I joined one startup, "Hello World" took 240msec, a rearchitecture (without something as drastic as HipHop) dropped it to 15msec. I don’t think latency would be a win at that point alone. My guess is similar improvements can be found at other companies that are >90msec. However that is not always the case: Rasmus feels this may be a win for frameworks—their bloat usually destroys response time.

      In Facebook‘s case, all the "big latency" hurdles were eliminated when they moved to lazy-loading APC, they are clearly thinking about eliminating even more with the ability to snapshot the core and restart from there (that that approach is highly complex). And their big issue is sheer cost, not latency. So to them total time matters and latency is simply a matter of running the servers sparsely.

      Unfortunately I cannot quote Facebook’s numbers on CPU time. You will have to ask them, or figure it out yourself by the copyright trick.
      My recent post Faster PHP fo shizzle—HipHop for PHP

  1. Maybe I came off wrong in my comment but it was more a reflection of the hype and not the technology.

    I shouldn't have acted so quickly to say that WordPress used eval all over the place because as you say that isn't correct. I was trying to find the least complicated reason to give for why people using WordPress shouldn't bother.

    My last resort comment was based on there not being much more you can do to speed up PHP than compiling it to binary. If there were then Facebook would have done that instead. That isn't a bad thing but it is a reflection of what people will be using the tool for.

    The hype around HipHop makes it out to be something everyone that uses PHP will be using (that is why you get comments like Patric's about how great it will be for WordPress users). You need to be committed to using PHP compiled with HipHop. I'm sure the hype will die down but what is worrisome is that people who don't understand what to use it for will fail in their attempts and complain about it.

    On another subject, does anyone know when it is it going to be released? I want to actually use it so my comments are based on some reality.
    My recent post Developing Adobe Air Apps with Linux

    1. Hmm, what part of “possibly” did you miss?

      In any case, it depends on the benchmark, but if the benchmark is artificial enough (like many of those in the Alioth shootout), then the static analyzer can replace nearly everything with native C++ calls. At that point, you’re basically benchmarking Java vs. C++, not PHP.

      If you look at the same tables you reference, you’ll note that C++ does better in CPU usage than Java. Both C++ and PHP (native) already do miles better than Java in total memory usage (because of automatic garbage collection).

      In practice, I’d say it puts them in the same class in terms of CPU—mostly slightly slower, but a few times much faster. This should come as no surprise because Java has a JIT and HipHop is a cross-compile to C++ which is a straight compile.
      My recent post Faster PHP fo shizzle—HipHop for PHP

  2. HipHop is interesting but, I'll definitely argue about it being PHP. By picking and choosing what language features they'll support they're building a language kinda sorta like PHP but not quite PHP.

    Considering how many OSS apps and frameworks use eval() I also think it's disingenuous of them to characterize it as a rarely used feature. Now, maybe it's one that _should_ be rarely used but, that's a different argument.
    My recent post HipHop for PHP is not PHP

    1. I understand what you’re saying but it’s a losing argument. The frameworks you mention that can’t implement HipHop almost all because they depend on dynamic scripting of template pages for performance. That would no longer be needed in HipHop.

      I’m not saying you are wrong right now, I’m just saying that it’s a lot easier to port frameworks than you think. They simply have to add a flag to allow you to turn off any dependency on dynamic scripting components like Smarty. They shouldn’t be necessary to run the base framework.

      Before HipHop, there was no reason to not do dynamic scripting and a whole host of reasons why performance improves when you do. Now, HipHop changes that cost-benefit. To not expect framework developers (who I feel have as a failing their alacrity in which they adopt anything new), to change due to that is short-sighted.

      I argue in the article why OSS apps probably won’t change.
      My recent post Faster PHP fo shizzle—HipHop for PHP

  3. Oh, I think that much of the OSS world will adapt and quickly. Supporting HipHop will likely become a checklist feature and looking at the usage of eval() in some projects it would be trivial to remove. I mainly cited them as part of taking issue with their "rarely used feature" characterization.

    My larger point is that instead of actually supporting the PHP language, they're moving the goal posts to a position more convenient for them and calling it PHP. For better or for worse, eval() is part of PHP.
    My recent post HipHop for PHP is not PHP

  4. Oh, I think that much of the OSS world will adapt and quickly. Supporting HipHop will likely become a checklist feature and looking at the usage of eval() in some projects it would be trivial to remove. I mainly cited them as part of taking issue with their "rarely used feature" characterization.

    My larger point is that instead of actually supporting the PHP language, they're moving the goal posts to a position more convenient for them and calling it PHP. For better or for worse, eval() is part of PHP.
    My recent post HipHop for PHP is not PHP

  5. I'm interested in what language features besides eval() are not supported. They give eval() as an example but imply there are others. Seems kind of important to be able to consider what will and will not be available before getting TOO excited…

    1. I have a list of some which I’ll get to when I finish the article but here is a quick rundown off the top of my head.

      – eval() not supported
      – dynamic scripting is not allowed (That's where you use PHP to create a PHP file. Like when you use Smarty to compile a file).
      – create_function() is not supported
      – preg_replace when using e (execute PHP code on match)
      – some functions are not implemented yet/were overlooked (An example was that was php_version() was not returning anything which was crashing HPHPi when it was running against the WordPress codebase. These bugs should be reported and fixed though.)

      …and there was something to do with ordering where it works in PHP but won't when the static analyser hits it. Meaning in some of your scripts you may have to move things around for it to work.
      My recent post Faster PHP fo shizzle—HipHop for PHP

  6. hiphop won’t change the fact that php is a language most people grow to hate. i don’t know anyone who likes it more after a year than they did on day 1. so hiphop doesn’t make the rewrite argument go away. it might delay it, but inevitably the pain of actually writing and maintaining php remains.

    1. You dance with the one who brung you.

      I didn’t advocate when Friendster decided to switch from Java to PHP. I didn’t advocate when Del.icio.us decided to switch from Perl/Mason to PHP/symfony. I don't advocate anyone switch to PHP because of HipHop on PHP. Why would I start arguing that a company leave PHP because apparently according to your limited experience nobody "likes it after more than one year"?

      Architecture changes are hard because they are inherently waterfall. They are especially hard since the web development cycle is tight (if the company is any good). If you want to shoot yourself in the head, (or if you are a consultant, cause your clients to shoot themselves) be my guest.
      My recent post Faster PHP fo shizzle—HipHop for PHP

      1. "I guarantee those engineers who failed were a lot smarter than you."

        ? you don't even know who the hell i am. i single-handedly created the most popular news website in the world, which has been #1 for a decade. you can piss on that too or you can admit maybe you and your cabal are by no means the last word in who knows how to build websites.

        1. No, I don’t know who you are. The fact that you hide behind a curtain of anonymity while I don’t speaks volumes as to your authority.

          You’re afraid to put up, therefore you get shut down.

          Unlike you, I am never secret in my affiliations. Thus, to my knowledge, I’m not part of a cabal. But, I would like to know the number of your crack dealer, since you are obviously on it. 😀

    2. I started using PHP for side projects about 8–9 years ago. I started using it as one of my primary responsibilites at work about 4 years ago. While I don't recall exactly how much I liked it 9 years ago, I'm quite fond of it now.

      Poorly designed code is painful, regardless of its language, and "the pain of actually writing and maintaining [code]" is part of software. I don't see how that's unique to PHP.

    3. I started using PHP for side projects about 8–9 years ago. I started using it as one of my primary responsibilites at work about 4 years ago. While I don't recall exactly how much I liked it 9 years ago, I'm quite fond of it now.

      Poorly designed code is painful, regardless of its language, and "the pain of actually writing and maintaining " is part of software. I don't see how that's unique to PHP.

  7. Pingback: abcphp.com
  8. It's a shame that so much time has been wasted creating a PHP to C++ cross compiler. Sure, it will help Facebook, and some other large websites in speeding up their systems, but it encourages more PHP usage, which is a downright awful language. PHP needs to die.

    Also, your arguments about PHP being a more universally supported language than some other scripting languages is archaic. Shared hosting is approaching the end of its lifetime, and anyone who wants to create a Python/Ruby/Scala/etc website will be able to do so thanks to on-demand cloud computing.

    TLDR: PHP is dead. Get over it.

    1. Ahh, another anonymous comment with a blanket “PHP is bad” statement and no evidence to back it up. Did I get slashdotted and no one tell me?

      Shared hosting may be EOL for those people doing Web 2.0 startups, but for the SME market it is not only alive and well, but thriving. The SME market is many orders of magnitude larger than Web 2.0 startups—talk to GoDaddy sometime before you make that claim. In fact, I’ve noticed that 3 of the top 3 open source CMSs (which pretty much own about 90% of the open-source CMS market) are written in PHP. Shared hosting was instrumental, and no amount of slicehosting will eliminate that, since slicehosting is not used by non web-based SMEs.
      My recent post Faster PHP fo shizzle—HipHop for PHP

  9. "phalanger? – MS bought the team, they’ve disappeared"

    Are you sure about that? Phalanger is alive and well and being developed to a new version (3.0) by a UK Software company and a team at CHarles University. It's being deployed in the Enterprise and in Government.
    My recent post Drumma Boy discography

  10. "phalanger? – MS bought the team, they’ve disappeared"

    Are you sure about that? Phalanger is alive and well and being developed to a new version (3.0) by a UK Software company and a team at CHarles University. It's being deployed in the Enterprise and in Government.
    My recent post Drumma Boy discography

  11. I also think that many developers will not use it, as many people say it only makes sense if you know what you are doing, if the problem is cpu/memory AFTER profiling the code, and if you have at least 3 servers and you can perhaps save one of them.
    I'm really interested in the source code, examples, "compatibility lists", translated extensions and so on, this will take a while until we are able to use it I think.
    My recent post HipHop für PHP

    1. That is like the assertion that until 1994, COBOL was the language of choice, because it took that long for the new code to outstrip the legacy. And if you count ABAP/4 as COBOL, you could claim it came even later.

    2. Wow, passing C++ and Visual Basic. That’s phenomenal (and unexpected).

      Still most problems can be solved with any language. I feel even Facebook’s could have been. The issue is that language would have come with its own baggage.

  12. I too have a question about the 'only worthwhile if you're big' sentiment: wouldn't improved memory efficiency be very important to a site that's running on a tiny VPS? Or are the memory gains not really that substantial?

  13. You are too pessimistic, HipHop PHP is going to change everything!!!! Be more excited and happy my friend, this enable developers to streamline other development concerns by increasing performance.

    For instance, our development cluster in-house is larger than our production because we do massive testing (i.e. download the entire site and analyze it). This will be a great win for many development teams if harnessed correctly.
    My recent post HipHop PHP is going to save the world

  14. Terry, can you , please, notify people somehow (twitter probably) once you finish this article? I don't want to check every week if you updated it (or not). That would be nice.

    And, it seems like there is some issue with displaying/formatting posts' dates on your blog.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.