Slashdot Mirror


Benchmarking 3 PHP Accelerators

jfbus writes "PHP, like all scripting languages, suffers from having to parse all script files each time a page is displayed. Accelerators (opcode caches) are necessary to speed PHP enough for large websites. Here is a benchmark of the major PHP accelerators (Zend platform, apc and eAccelerator)."

9 of 81 comments (clear)

  1. Like all scripting languages? by Bogtha · · Score: 3, Informative

    PHP, like all scripting languages, suffers from having to parse all script files each time a page is displayed.

    This isn't something common to all scripting languages. For example, when Python scripts are executed, they are compiled to byte-code, and the result is saved for faster execution next time. Of course, in typical web hosting situations, the web server doesn't have permission to write to the filesystem, but you can quickly and easily compile the bytecode yourself. ASP.NET also compiles once only.

    In fact, I believe it's an oddity of PHP that it needs add-ons in order to do this, and I think the next version of PHP will have fixed this. I don't know where they got the idea that all scripting languages must always parse the script on every invocation.

    --
    Bogtha Bogtha Bogtha
    1. Re:Like all scripting languages? by suv4x4 · · Score: 2, Interesting

      In fact, I believe it's an oddity of PHP that it needs add-ons in order to do this, and I think the next version of PHP will have fixed this.

      That's one of Zend's main revenue sources. They developed PHP, they developed the accelerator. But they sell the accelerator and offer PHP free with sources as a lure.

      What I'm saying is, no, it won't be fixed in the next version of PHP.

    2. Re:Like all scripting languages? by Bogtha · · Score: 2, Insightful

      Rasmus Lerdorf has posted a PHP 6.0 wishlist that includes an opcode cache. Rasmus is the founder of the PHP project.

      Zend might sell an accelerator, but that doesn't mean they can simply forbid the founder of PHP from adding the feature to his own project. At this point, I think the question is which opcode cache gets added to PHP, not whether it will happen.

      --
      Bogtha Bogtha Bogtha
    3. Re:Like all scripting languages? by Just+Some+Guy · · Score: 2, Informative
      Does any language do that?

      Python's loading algorithm goes something like this:

      1. A module tries to import another module named "foo".
      2. Find "foo.py" in the search path.
      3. Does "foo.pyc" ("c" for "compiled") exist in the same directory? If so, is it newer than foo.py? If both are true, then load it.
      4. Otherwise, compile "foo.py" and attempt to write the compiled bytecode to "foo.pyc".

      Never in my time developing Python have I once encountered a problem with stale compiled objects. If your language of choice doesn't have this same functionality or its equivalent, then the problem is with the language and not the concept.

      --
      Dewey, what part of this looks like authorities should be involved?
  2. Re:Forgive me for my stupidity, by tonigonenstein · · Score: 2, Informative

    In such a case you would compile each version of the function and implement the condition by an opcode that put a reference to the correct version into a pointer. Then every call to the function use the reference contained in the pointer. In a word, you use indirect function calls.

    --
    The sooner you fall behind, the more time you have to catch up.
  3. Turck MMCache by slashflood · · Score: 2, Informative

    What about Turck MMCache?

    1. Re:Turck MMCache by hhnerkopfabbeisser · · Score: 3, Informative

      The project died when the developer was hired by Zend. Last Version released in late 2003.

      Reincarnated here: http://eaccelerator.net/

  4. Re:"Accelerating" PHP is a waste of time by fractalus · · Score: 2, Insightful
    PHP may indeed be crap, but not for the reasons you specify.

    • Whether you prefer Perl-like syntax (that PHP uses) or VBScript syntax is largely a matter of preference. I've personally found that VBScript is more of a pain in the ass than PHP.
    • You can have ADO if you want it, or you can use PDO which does support parameterized queries. Or you can use mysqli instead of mysql.
    • I honestly found VBScript lacking more basic convenience functions than PHP ever did.


    The extension model may be a matter of taste. I'll give you the benefit of the doubt. PHP's handling of multiple form fields with the same name does suck, but at least it isn't too hard to work-around (just re-parse the posted data the way it should have been done).

    PHP security doesn't suck any worse than ASP or Perl or ColdFusion or anything else, once you disable things like magic_quotes and register_globals (which is recommended practice). However, there's a lot of crappy PHP code floating around, and if you're new to web programming, you don't know enough to tell the good code from the bad. Nor do you really grok the notion that your code can be hammered on by every malcontent on the planet. Those problems are also not unique to PHP. But since PHP is so widely available, lots of amateurs write code with it.
    --
    People are never as simple as their stereotypes. This applies equally to Christians, Muslims, and Emacs-lovers.
  5. Re:"Accelerating" PHP is a waste of time by mogrify · · Score: 2, Informative

    /* libAnonCoward.php */

    function Redirect($location) {
      header("Location: $location");
      die;
    }

    function MapPath($file) {
      return realpath($file);
    }

    --
    perl -e 'foreach(values %SIG){$_="IGNORE";}while(){}'