Slashdot Mirror


Facebook Releases JIT PHP Compiler

angry tapir writes, quoting a Techworld article: "In its continuing endeavor to serve its 800 million users as quickly as possible, Facebook is once again revamping the way it handles its PHP-based Web pages. Facebook has posted ... its HipHop Virtual Machine (HHVM), which the company's engineers call a just-in-time PHP compiler. According to Facebook, this PHP execution engine is 60 percent faster than its current PHP interpreter and uses 90 percent less memory." Facebook has a weblog post with a more technical description.

39 of 244 comments (clear)

  1. First PHP post by PCM2 · · Score: 5, Funny

    I'd like to launch this discussion by making a snide remark about PHP.

    --
    Breakfast served all day!
    1. Re:First PHP post by Anonymous Coward · · Score: 5, Funny

      Aren't Facebook programmers already tools?

    2. Re:First PHP post by MattW · · Score: 5, Funny

      It's too bad PHP doesn't scale.

  2. Yo Dawgs! by syousef · · Score: 3, Funny

    Da Hip Hop PHP compila is in Da House! Respect bitches!

    --
    These posts express my own personal views, not those of my employer
    1. Re:Yo Dawgs! by binarylarry · · Score: 3, Funny

      Yo dawg I heard you like PHP, so we put an optimizing JIT compiler in your PHP runtime, so you can execute PHP code while you execute PHP code!

      --
      Mod me down, my New Earth Global Warmingist friends!
    2. Re:Yo Dawgs! by MrEricSir · · Score: 5, Funny

      Yo dawg I heard you like interpreting PHP code, so we put an eval() function in PHP so you can interpret PHP while you interpret PHP!

      --
      There's no -1 for "I don't get it."
    3. Re:Yo Dawgs! by iluvcapra · · Score: 5, Funny

      Yo mama's so fat, she thinks strstr(needle, haystack) and strstr(haystack, needle) both sound delicious, she just can't ever remember which one is the one to use.

      Yo mama's so fat, she hides food in $a[1] and $a["1"].

      Yo mama's so fat, she silently coerces strings into sandwich, and when the interpreter complains, she puts an @ sign in front of it.

      --
      Don't blame me, I voted for Baltar.
  3. Re:Mixed feelings by yelvington · · Score: 5, Insightful

    That's a step forward for us who rely on crammed share hosting providers, but I strongly believe that PHP has to be phased out in favor of more recent techologies that enforce a clearer (eg DRY, separation of content and logic etc) way of thinking.

    Programming languages don't create programming messes. People do.

  4. Is it open sourced? by Taco+Cowboy · · Score: 4, Insightful

    Is FB's JIT PHP open sourced?

    --
    Muchas Gracias, Señor Edward Snowden !
    1. Re:Is it open sourced? by PCM2 · · Score: 5, Informative

      Is FB's JIT PHP open sourced?

      It appears to be licensed under a combination of the PHP license and the Zend license. Both are BSD-like, but the Zend license has a clause that requires you to advertise for Zend if you advertise for a product built with the Zend Engine, which I don't much care for.

      --
      Breakfast served all day!
    2. Re:Is it open sourced? by Anonymous Coward · · Score: 5, Informative

      If it's not, back to Xcache or APC.

      Their "10 times figure" is absolutely correct though, in both Xcache and APC, the compiled binaries to take up 10 times as much space on disk and/or in memory, but to put things in perspective, that's caching memory. It was already consuming that 10 times size when being run directly from php before.

      Memory pigs like wordpress eat like 64MB of memory before you even get to plugins. Memory deduplication is required if you are running multiple blogs because the cache files generated by things like SuperCache and MaxCDN also eat up the opcode cache space.

      Fun times.

      #1 rule of php memory management: NEVER inline html. Many people use it as a easy way to do SSI, but this eats memory, opcode cache or not.

    3. Re:Is it open sourced? by nzac · · Score: 4, Informative

      Its on github and depends on open-source libraries.

      from the github page:

      HipHop is licensed under the PHP and Zend licenses except as otherwise noted.

      Its opens source but not copyleft/gpl and if you want to contribute to the project i think you have to sign over the copyright (need facebook login to see the agreement).

    4. Re:Is it open sourced? by ksd1337 · · Score: 5, Funny

      Hey, he's got a 4-digit UID! Respect your elders!

    5. Re:Is it open sourced? by PCM2 · · Score: 4, Interesting

      The Zend Engine license seems contradictory to me. On the one hand, Clause 3 says you're forbidden from using the terms "Zend" or "Zend Engine" to endorse or promote your product. On the other hand, Clauses 5 and 6 say you're absolutely required to use the term "Zend Engine" to endorse and promote your product. Seems like someone took the classic BSD license and bolted a commercial land grab onto it, which seems to honor neither the letter nor the spirit of the original.

      --
      Breakfast served all day!
    6. Re:Is it open sourced? by youn · · Score: 4, Funny

      I believe it is a license meant for quantic processors... it is required and not required at the same time

      --
      Never antropomorphize computers, they do not like that :p
    7. Re:Is it open sourced? by Tom · · Score: 5, Funny

      Pffft. Newbie.

      --
      Assorted stuff I do sometimes: Lemuria.org
    8. Re:Is it open sourced? by TheRaven64 · · Score: 3, Insightful

      No, you must use your product to advertise theirs, you can't use theirs to advertise yours. It's the same as the old BSD license. You must include 'built using Zend's stuff' somewhere in your documentation, but you can't say 'really amazing because it uses Zend's stuff'.

      --
      I am TheRaven on Soylent News
  5. Re:Mixed feelings by Etz+Haim · · Score: 3, Insightful

    I was expecting this. You could argue that, and also add to it that there are PHP frameworks out there that do DRY, MVC etc. The problem is that PHP itself, by allowing "mixed mode" scripts containing both HTML and PHP, teaches a programming paradigm that is unacceptable by modern standards.

  6. Re:Mixed feelings by vinng86 · · Score: 5, Insightful

    You must be knew to programming. PHP is a language, not a framework. You can use a PHP framework to apply a MVC (model/view/controller) structure or you can choose not to. It's entirely up to the programmer, not the language.

  7. Re:Mixed feelings by John+Courtland · · Score: 4, Insightful
    Bullshit. PHP's standard library is a piece of shit that certainly promotes bad coding practices. Case in point: http://us3.php.net/manual/en/function.implode.php

    And I quote:

    implode() can, for historical reasons, accept its parameters in either order. For consistency with explode(), however, it may be less confusing to use the documented order of arguments.

    --
    Slashdot is proof that Sturgeon's Law applies to mankind.
  8. Re:Mixed feelings by InsightIn140Bytes · · Score: 4, Insightful

    No it doesn't. It's entirely up to you how you use an programming language. It's good that PHP supports "mixed mode" and everything between. Hell, I've made IRC server with PHP along with desktop apps and everything else.

  9. What's your problem? Very well documented! by syousef · · Score: 5, Funny

    And I quote:

    implode() can, for historical reasons, accept its parameters in either order. For consistency with explode(), however, it may be less confusing to use the documented order of arguments.

    What is your problem with this exactly? The functions do exactly what their name suggests. They will either make your head implode or explode!

    --
    These posts express my own personal views, not those of my employer
  10. Re:So True. by Jack9 · · Score: 4, Insightful
    --

    Often wrong but never in doubt.
    I am Jack9.
    Everyone knows me.
  11. Re:Mixed feelings by CodeReign · · Score: 5, Funny

    You are a disgusting filth and I will loath the existence of people who don't use the right tool for the right job for the rest of my life.

  12. Re:So True. by Rennt · · Score: 4, Funny

    It's a form of hacker koan. In your eagerness to be a smartass you failed to reach enlightenment.

  13. Re:Mixed feelings by Anonymous Coward · · Score: 5, Insightful

    Yeah cause PHP is so bad Facebook use it... no programming language is perfect, they all have their quirks. But your comment is baseless, PHP doesn't make bad programmers, it just doesn't break your legs if you are one.

  14. Re:Mixed feelings by InsightIn140Bytes · · Score: 5, Insightful

    You are a disgusting filth and I will loath the existence of people who don't use the right tool for the right job for the rest of my life.

    You know, people who do fancy stuff with not exactly the right tools were called "hackers".

  15. Re:Mixed feelings by MightyMartian · · Score: 5, Informative

    PHP is like BASIC. In the right hands it can certainly produce just as readable and maintainable code as any other language, but the short learning curve to get to first base invites people with little or no discipline, or often enough, without any underpinnings at all, to write absolute garbage. Worse, this code often ends up being the core of some important infrastructure, and then some poor yob (I was one for several months) has the unlucky job of trying to maintain this garbage. And because the php.ini file allows you turn on all the worst aspects of the language, you end up having to do just that just to keep the damned code running while you try to clean it up.

    Oh yes, and apart from the issues I have with the language itself, it has just a plain awful library, with inconsistencies throughout that mean I spend as much time perusing the docs as I do actually coding anything.

    Between these two factors, I have to say I hate PHP, but still find myself all too often being forced to deal with it.

    --
    The world's burning. Moped Jesus spotted on I50. Details at 11.
  16. Re:Mixed feelings by MightyMartian · · Score: 4, Insightful

    Which means it won't be. PHP has taken hold, and good, bad or ugly, we're stuck with it. There's no phasing it in anything like the short or even medium term. LAMP is everywhere, and countless sites are built on it. It's like COBOL, a bad dream that will keep terrifying us even as better languages flicker and die.

    --
    The world's burning. Moped Jesus spotted on I50. Details at 11.
  17. dev only by Fnord666 · · Score: 3, Insightful

    Unless I misunderstood the post, this is only being used in their development environments. It sounds like they are still using statically compiled php for production. They did mention that they hoped to closed they gap in performance between the two in the near future though.

    --
    'The tyrant will always find pretext for his tyranny.' - Aesop's Fables
  18. Re:Mixed feelings by shutdown+-p+now · · Score: 3, Insightful

    You know, people who do fancy stuff with not exactly the right tools were called "hackers".

    Only when it's either hard to do so, or when doing that is some kind of a pun. When the only hallmark of such a work is that the result is a bloated mess...no, hacking doesn't have much to do with it.

  19. Re:Mixed feelings by garyebickford · · Score: 4, Insightful

    Ya know, about 30 years ago, that statement could have been written thusly:

    C programs are per se incompatible with the structured programming model. It's a bad programming practice and if you use it, you are doomed to repeat yourself.

    Your statement is pretty much equivalent to "never end a sentence with a preposition".

    Structured programming eventually failed to take over the world because it imposed too much artificial, restrictive structure. Back then I remarked that "structured programming" was merely a way to force all programs to fit on a flat two-dimensional surface with no crossing lines. Admittedly, such programs are easier to analyze, but are a tiny, tiny subset of the set of interesting and useful programs. For example, one can look at the entire internet as one rather large, complex, multithreaded program.

    MVC is a good model, but it ain't the be-all and end-all. All models are an attempt to impose an rational order on what is essentially a linguistic medium (with a veneer of logic). The languages that survive are those that allow the maximum flexibility, with enough support for the tools of analysis and good practice to allow programmers to succeed. C, for example, continues to succeed because it does not have such artificial constraints, but can be adapted to the constraints that the programmer (and the organization) considers important at the time. As a counterexample, see Pascal, or Algol. And don't forget Gõdel.

    So, use MVC and DRY. But one day you will find a situation where they get in the way of the most elegant solution. Or, more likely, they will get in the way of hacking a new feature into some legacy POS in time to meet the deadline that Marketing already promised to the client! :D

    --
    It's easier to be a result of the past, but more fun to be a cause of the future! http://www.spacefinancegroup.com/
  20. Re:Mixed feelings by trawg · · Score: 5, Interesting

    I disagree that it promotes bad coding practices. I read that as a bit of a tongue-in-cheek comment that actually encourages people to use it the right way, while at the same time drawing attention to the fact that you can swap parameters and you might get unexpected results (i.e., the function working even though it should throw some sort of type error).

    Sometimes mistakes are made in libraries and terrible ugly hacks have to be made to work around them so as not to destroy many hours of work. Whether or not PHP has its share doesn't mean the blame for writing terrible code should be laid entirely at its doorstep.

    Certainly a few crappy library functions hasn't soured Facebook on PHP; I for one am glad to see their continued investment in it and - more importantly - their continued practice of open sourcing new and innovative ways of dealing with PHP.

  21. Re:So True. by PCM2 · · Score: 4, Interesting

    Which is at least 50% slower on its best day, than C/C++ on it's worst day.

    Got any numbers to back that up, or are you just pulling it out of thin air?

    It's the VM part that kills performance. The Java VM, and presumably, the PHP VM, do not execute native machine instructions, but instead, use an intermediary format, as opposed to, native cpu instructions.

    You don't seem to understand how a JIT works. Many portions of Java programs are indeed executed as native machine instructions.

    Combine that with the remarkable similarity between PHP syntax and C ( but without the speed )

    I wouldn't call the similarity "remarkable." "Superficial" might be a word I'd use, in the sense that Java syntax is also similar to C.

    --
    Breakfast served all day!
  22. Re:Mixed feelings by Zero__Kelvin · · Score: 5, Funny

    "You know, people who do fancy stuff with not exactly the right tools, when the right tools were not available, ARE called "hackers".

    FTFY.

    People who use the wrong tool when the right tool is available are called PHP programmers ;-)

    --
    Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
  23. Re:Mixed feelings by cshark · · Score: 5, Interesting

    You know, you hear that kind of weird argument a lot from people who don't realize they've been framework programming on Microsoft platforms. They are always complaining about how primitive PHP is because it doesn't have any "built in" separation between the various heavily abstracted but highly arbitrary layers, and that they don't understand the way PHP abstracts logic, variable classes, magic methods, lambada syntax, etc. They're always pointing to perceived shortcomings in PHP, like the one data interchange layer they know about, or the fact that PHP doesn't pass complete classes as strings. The list goes on for fucking ever. The intentional ignorance of these people annoys the holy shit out of me. Or, well... it used to.

    You know, by the same criteria these "evangelist" idiots are using to judge PHP, and failing to apply their idea of "modern", they would be sorely disappointed with any number of other languages. PHP is C++ script. Plane and simple. So if you hate PHP, or you simply can't bring yourself to understand it, it's fair to assume you wouldn't like like C++ either. And for that matter, you certainly wouldn't enjoy Perl, any version of C (other than the sharp kind), Python, Ruby, Java, or any other modern language not developed by our friends in Redmond. None of them would be "modern" enough for you. Or maybe, you're just not skilled enough at your chosen craft. Nobody will ever appreciate the artist who refused to paint because he didn't like the brushes.

    PHP isn't the only language that people have written mountains of bad code on either. If you could even begin to understand the mountain of truly nightmarishly bad .net code I've had to wade through over the last decade, you would give me a fucking medal. In fact, I would wager to say that it's easier to write a large, poorly architected application in C# than it is to write one in PHP. Why? Easy. Because Visual Studio doesn't require you to actually think a whole hell of a lot about what you're coding.

    When you write something in PHP, it's a direct reflection of your ability to code. That's all it is. Code. Start to finish. You think out a problem, and then you write the code to do it. If you want to seperate it into objects, classes, or layers, you're entitled to. If you have another way to do it, that's also fine.

    PHP gives you absolute control and power over whatever it is you want to create. If you're not used to it, or ready for that kind of responsability, it can be frightening.

    So I totally understand why lesser programmers hate it.
    Personally, I like having options.

    --

    This signature has Super Cow Powers

  24. Re:Mixed feelings by aztracker1 · · Score: 3, Interesting

    Honestly the syntax of the language doesn't bug me nearly so much as the inconsistancy_in TheApi andItsCommonLibraries. Some use pointers/handles as psuedo classes, or just plain poorly conceived and inconsistent string and array handling. I know there are frameworks on top of PHP that sterilize a lot of this, it just feels like building a house on sand. There are honestly very few web frameworks I really like, and I've worked with many of them. C# + MVC is a fav, but I've seen some wretched code in C# as well. Usually derived from "software architects" who will abstract everything out ad infinitum and sometimes to no point at all. I'm all for IoC and other abstractions and models when they serve a purpose. when you only need 5-10 method calls for a very simple web-app, it's overkill.

    C#'s greatest downfall is those developers/architects that will over-engineer what can be a simple system. PHP's greatest downfall is the sheer popularity in un-trained, or ill-thinking programmers that give the same level of bad taste VB did in the 90's for a lot of people. Bad code can indeed be written in any language, but when a language's core functionality is so poorly conceived, it's harder to write good code. For the record, not very fond of C/C++, but do like Perl okay (for text processing).

    --
    Michael J. Ryan - tracker1.info
  25. Re:Mixed feelings by mcrbids · · Score: 5, Insightful

    Certain, I'm going to get modded to oblivion for this, but....

    Brother I hear your music! PHP is highly underrated! It's a language flexible enough to allow you to just stick a date stamp in the middle of a random webpage, and also write a highly complex, object-oriented application framework with gorgeous abstractions.

    Performance is decent, sources are open and don't require compiling, and it's compatible with every webhost and platform out there. It scales well with it's "share nothing" approach, and is one of the most stable software packages I've ever seen. Oh, and the Documentation is excellent.

    Sure, it has it's warts: dynamic typing means that in the right contexts, 1==0, and a few others, but these are edge cases in every situation that matters. Most of the problems with OOP in PHP4 have been fixed with the now-almost-universal PHP5.

    I can do c, c++, Python, Perl, Javascript, Java, etc. but PHP is my favorite as the Chrysler K-car that doesn't win any looks contests, but always starts and gets you where you want to go, even if only at the legal speed limit.

    --
    I have no problem with your religion until you decide it's reason to deprive others of the truth.
  26. Re:Mixed feelings by dingen · · Score: 3, Informative

    The language changes too rapidly

    Erm... what? Have you actually looked at the changelog in the past few years? It's all bug fixes, there's absolutely nothing interesting going on there! Development in PHP has completely stagnated for years now. PHP 5.2 was released in 2006 (!!!) and still not everybody has caught on. Then 5.3 came out 3 years later, but it's even rarer to encounter that in the wild. The differences are totally marginal and the stuff they're deprecating is mainly bad stuff from PHP3 and PHP4 that you shouldn't have been using in anything for the last couple of years anyway.

    There's a lot wrong with PHP and there's a lot of bad stuff in there, but in my opinion the worst thing about PHP is the lack of progress to improve things. So no, I don't agree the language changes too rapidly, I think it's changing not nearly rapid enough.

    --
    Pretty good is actually pretty bad.