Slashdot Mirror


Parrots, Pythons And Things That Go Splat

ajs writes "As you may know, there was a contest between Dan Sugalski and Guido van Rossum over the performance of Parrot running Python byte-code, and the loser was to take a pie in the face. Well, in the end it was between Dan and time and Dan lost... he was unable to get the Python bytecode translator to work sufficiently well for the contest (it was fast, but not complete), but when Dan conceded, Guido was gracious enough to decline to throw a pie, what a sport! The Perl community, however, was not quite so gracious (they wanted to see Dan take a pie for the team), and the final event ended up being a benefit for the Perl Foundation. Meanwhile, see Dan's Blog for details on what sorts of Parrot goodness came of this."

43 comments

  1. IronPython by Hard_Code · · Score: 4, Interesting

    Huh? IronPython is even faster that the normal C impl, so I guess it was more a contest of the Parrot VM than it is php vs. python. Don't worry, I have faith Parrot will be as good as the other VMs (Java, Mono) and at least on par with, but most probably faster, than a hand-rolled php engine.

    --

    It's 10 PM. Do you know if you're un-American?
    1. Re:IronPython by CableModemSniper · · Score: 2, Informative

      Where did you get PHP from? It was CPython vs. Parrot Python. (well a translator that turns python bytecodes into parrot byte codes anyway)

      --
      Why not fork?
    2. Re:IronPython by Hard_Code · · Score: 1

      woops, confoozled my guido-van-rossums with my rasmus-lerdorfs...

      --

      It's 10 PM. Do you know if you're un-American?
    3. Re:IronPython by Anonymous Coward · · Score: 5, Informative

      Huh? IronPython is even faster [slashdot.org] that the normal C impl, so I guess it was more a contest of the Parrot VM than it is php vs. python. Don't worry, I have faith Parrot will be as good as the other VMs (Java, Mono) and at least on par with, but most probably faster, than a hand-rolled php engine.

      Let's not jump to conclusions, everyone. While he did lose the challenge, it seems that he lost itbecause there simply wasn't enough time to implement the functionality required to run the python scripts on the Parrot interpreter. Hopefully, the parrot interpreter would win this contest if it the developers had more time. See below for a quote from the concession:

      This concludes the effort to implement the Pie-thon benchmark for
      OSCON, because there isn't any chance to implement the needed bits for
      b0.py in the remaining time.

      Four of seven benchmarks are running: b1, b2, b3, and b6. b5 is done
      partially. Three of these are faster on Parrot, but e.g. while b2.py
      is running 3 times the speed of python, it takes just 0.2s here on a
      Pentium 600, which makes it hard to say, what's faster for these test
      collection.

      The benchmarks are mainly testing the speed of builtin functions,
      which are of course mature and optimized in Python, while a lot of the
      builtins just didn't even exist in Parrot a month ago. When it comes
      to just running arithmetic code, like in b2.py, Parrot is a lot
      faster.

    4. Re:IronPython by DAldredge · · Score: 2, Funny

      You know, IronPython causes major problems for my sig.

    5. Re:IronPython by Anonymous Coward · · Score: 0

      Sterling Hughes and Thies C. Arntzen are working on project-pint, PHP on parrot. Sterling was scheduled to give a talk on it at OSCON (found no coverage), I think I read in a comment of Dans (over @ ltu?) that Pint is shaping up nicely. I also recall that they are targeting imc (parrots intermediate language), go Spartacus go!

    6. Re:IronPython by anonymous+cowherd+(m · · Score: 2, Informative
      You also have to keep in mind that IronPython is not yet a complete implementation. I love python as a language, and if IronPython turns out to be faster than CPython in a way that matters to me, then I'll switch. I'm not tied to a particular implementation at all.

      OTOH, I do think it's going to be pretty hard to beat the combination of CPython and psyco. I've achieved speedups on code I've written of up to 24x, and it's claimed one can get up to a 100x speedup on certain limited types of code.

      OTOOH, the types of code that psyco tends to speed up that dramatically tends to be rather non-pythonic in my experience. My best experience was with number crunching code using regular ints -- that's clearly a job for a C extension and I fail to see how any VM can beat raw C consistently for that type of code, unless it has one hell of a JIT compiler. But then, that's exactly what psyco is...

      --
      http://neokosmos.blogsome.com
    7. Re:IronPython by Hard_Code · · Score: 2, Interesting

      What is interesting to me is dynamic optimization of long-running processes through a dynamic jit/unjit. Java has one, but as far as I know Mono/.Net does not (all the compilation is up-front, not while it runs).

      I think a lot of these performance comparisons will become moot in the face of a runtime optimizer because who's static optimizations are better than others' won't matter when you have an optimizer that operates at runtime and dynamically inspects what code is actually being executed and optimizes that. I sure hope Mono/.NET get a dynamic runtime optimizer. It will make all these arguments pointless.

      --

      It's 10 PM. Do you know if you're un-American?
    8. Re:IronPython by Anonymous Coward · · Score: 1, Interesting

      I think a lot of these performance comparisons will become moot in the face of a runtime optimizer because who's static optimizations are better than others' won't matter when you have an optimizer that operates at runtime and dynamically inspects what code is actually being executed and optimizes that.

      And life will be wonderful in heaven, where the lion lies down with the lamb[1] and baby Jesus is always smiling and the choir of saints sings sweet hymns to the Almighty and Java runs faster than C.

      Back in the real world, runtime optimisation is still an unproven pipe-dream. Static languages are still faster than dynamic languages and machine code is still faster than bytecode. Let's be realistic here - fusion power never happened, and it's quite possible that runtime optimisations beating compile-time optimisations will go the same way.

      [1] And we all know what "lie down with" means in the Bible. Like, ewww.

  2. Both slower than Java tho... by Anonymous Coward · · Score: 0, Insightful

    ...of course, one would not expect late-bound languages like Perl or Python to compete with Java in that regard. But in my experience PythonC runs my benchmarks at just over 1/10 the speed of HotSpot. Surely they can improve on that.

    1. Re:Both slower than Java tho... by Dan+Ost · · Score: 4, Interesting

      But in my experience PythonC runs my benchmarks at just over 1/10 the speed of HotSpot.

      Is that before or after you turn on psyco?

      --

      *sigh* back to work...
  3. No chance in hell by Anonymous Coward · · Score: 5, Insightful
    I have faith Parrot will be as good as the other VMs (Java, Mono)
    These languages make certain assumptions about typing and binding that Python and Perl do not. Additionally, Java's class structure is much *much* more time-efficient (though I rather like it less) than Python's memory-efficient proto-based object structure. It's the nature of the languages. It's why they're SCRIPTING languages. They traded speed for ease of coding. Which is just fine. But don't oversell them, you just look foolish.
    1. Re:No chance in hell by Anonymous Coward · · Score: 0

      why would you *ever* trade away ease of coding??

    2. Re:No chance in hell by DylanQuixote · · Score: 5, Interesting

      it is also worth noting that scripting languages tend to have a faster startup time than java-esque languages. In general, anyway.

      On my 450mhz PII, running a simple java application takes a few seconds to start, while the equiv. perl
      or python program starts up without any noticable delay.

      And perl has to compile the program before it runs it...

      Parrot vs. JVM is going to be very interesting,
      too. JVM is a stack-based VM, while I believe Parrot is register-based (like most real machines, actually. :) and I've heard this difference might prove faster.

      Plus writting in parrot asm is fun!

    3. Re:No chance in hell by davegaramond · · Score: 1

      Couldn't agree more. There are just some classes of programs that Java won't be able to do. CGI scripts for example. Or programs that have to be called several times in a second (like using it with tcpserver).

    4. Re:No chance in hell by gredman · · Score: 1, Informative
      CGI scripts for example.
      Isn't that what servlets are for?
    5. Re:No chance in hell by Anonymous Coward · · Score: 3, Informative
      it is also worth noting that scripting languages tend to have a faster startup time than java-esque languages.
      Yes, but that's a one-shot cost. True, for quick and dirty cgi-bin execution it piles up. But for anything that takes longer than several seconds it's lost in the wash.
      Parrot vs. JVM is going to be very interesting, too. JVM is a stack-based VM, while I believe Parrot is register-based (like most real machines, actually. :) and I've heard this difference might prove faster.
      This is largely an issue of translation. It's tougher (read: takes longer) to efficiently translate a stack machine into native code than it is an infinite register machine. But it's still quite doable. While Parrot (like .Net) is register-based, this is only a minor advantage which is quickly lost compared to the big stuff: Python is dynamically bound with a proto-style object lookup. That's the bottleneck. The other stuff is small potatoes.
    6. Re:No chance in hell by chez69 · · Score: 1

      yes, but being a perl haxor keeps him from saying anything good about java.

      --
      PHP is the solution of choice for relaying mysql errors to web users.
    7. Re:No chance in hell by Anonymous Coward · · Score: 0

      Oh please, stop being so defensive on your language. I use Perl as well as C, Ruby, PHP, Delphi, shell scripts. Ok, tell a webhosting company that hosts 1000+ users to replace CGI scripts (and PHP scripts, running as CGI) with servlets (and upgrade their 1GB RAM to 100GB).

    8. Re:No chance in hell by ajs · · Score: 1

      These languages make certain assumptions about typing and binding that Python and Perl do not.

      And which Parrot allows you to if you wish. You're discussing languages, not VMs, but responding to a comment about VMs.

      Additionally, Java's class structure is much *much* more time-efficient [...] than Python's memory-efficient proto-based object structure.

      Well, again you're comparing language features not VM features, and in this particular case, you're going to be dissapointed, because even in pure Python you can have non-prototype class definitions.

      It's why they're SCRIPTING languages.

      Actually no, the term "scripting" comes from the days when you would place a series of program names in order in a file and the OS could run them. It was like a script for a play, you write it down and it happens in that order.

      The term has blurred so much since then that at this point there is no actual reason. The ability to eval strings is often cited, but no one is calling Common Lisp a "scripting language" as far as I can tell. Speed if often cited, but speed trade-offs are being mitigated by increasingly powerful language features for specifying critical optimization information and by more powerful compilation tactics.

      No, "scripting" is a null word these days, which low-level languages use to dismiss high-level languages such as Python, Ruby and Perl. Java, C# and other "mid-level" language camps stand around watching this in what I can only guess is bemused smugness, but even that distinction is ending with the advent of Parrot. Running under Parrot, I see no reason for a Perl 6 program to be slower executing code than a Java program executing logically the same code. Typing and low-level behavior can be specified. Native types can be accessed. Classes need not be computed at run-time (though they can be). In general, I see Perl 6, and whatever the first versions of Python, Ruby and the rest are that truly take advantage of Parrot as being the first languages since Common Lisp that will manage to bridge the gap between mid-level and high-level languages completely.

    9. Re:No chance in hell by voodoo1man · · Score: 1

      Moderators, although I suggest that you take Eivind Eklund's advice into account, I can provide you with a shortcut to knowledge. Anyone who claims that proto[type]-based "object structures" (whatever those are) are "memory-efficient" is full of shit. I don't like to repeat myself, so I've dug up a past Slashdot post of mine (Slashdot makes this really hard to do - I think I would have saved time by re-stating my argument here) detailing the data requirements of an object in a prototype-based object system vs. an object in a traditional class-instance object system.

      --

      In the great CONS chain of life, you can either be the CAR or be in the CDR.

  4. Benchmarks aren't everything by hattmoward · · Score: 1

    Perl's speed actually surprises many, but speed isn't everything that should be considered in a language. The bet between Guido and Dan was on a completely academic level, not a pubescent drag race. =) Quick, get me a Java app that scans a set of maildir directories and outputs all messages by "TmdrCaco" to STDOUT in mbox format!

    1. Re:Benchmarks aren't everything by Electrum · · Score: 1

      Quick, get me a Java app that scans a set of maildir directories and outputs all messages by "TmdrCaco" to STDOUT in mbox format!

      That would almost certainly be limited by I/O speed, not the language.

    2. Re:Benchmarks aren't everything by hattmoward · · Score: 2, Informative

      Wha? What?

      Who said anything about the running speed? Didn't I just discredit that? The point was that a programmer knowledgable in Perl, Python, and Java would most certainly implement the program very quickly in Perl or Python.

    3. Re:Benchmarks aren't everything by Electrum · · Score: 2, Insightful

      My mistake. I totally missed your point the first time.

    4. Re:Benchmarks aren't everything by straybullets · · Score: 1

      i'd be interested to see the perl script for that :]

      --
      With that aggravating beauty, Lulu Walls.
    5. Re:Benchmarks aren't everything by ajs · · Score: 1

      You're right, and it had absolutely nothing to do with language comparisons (most of which are anatomy-waving competitions in the first place).

      The contest was about the value of a JITed VM vs the CPython (or Perl 5, for that matter) style of syntax-tree / bytecode walking. It was Dan's claim that Parrot would be faster at running Python bytecode than CPython and he was basing that on early data from Perl 5 running on Parrot. Since Perl 5 had been shown to execute faster than Python (on top of CPython) for certain operations and since Parrot ran that Perl 5 code faster than Perl 5, the assumption was that, at least in some cases, Parrot would be faster than CPython.

      Clearly there was a lot of room for Dan to lose on the merits of really being wrong, but IMHO equally as much of a chance to be right. We'll know someday when Parrot's Python front-end and Python-required back-end bits are at a state that this is more practical for the comparison.

  5. Registers versus Stacks by chromatic · · Score: 5, Interesting

    Parrot is indeed register based. At least when compared to Perl 5, this is a tremendous advantage. Perl 5's VM spends a lot of time fiddling with its stack (pushing a marker on, pushing arguments on, pulling arguments off and checking for a marker) that Parrot can avoid altogether. Of course, that means that Parrot needs to spend time saving and restoring register stacks, but Dan's position is that there's enough good research on the subject to make optimizations practical.

    Plus writting in parrot asm is fun!

    Tell me about it. I'm a day or two from checking in simple-but-useful OpenGL bindings.

    1. Re:Registers versus Stacks by Anonymous Coward · · Score: 0

      What is interesting for parrot is not that "It's register based" ...

      Btw, nobody writes parrot ASM anymore - except the cool kids. IMCC rocks because it has a register allocator (which is the HARDEST part of compilers).

      Imcc mixes assembly programming with the simplicity of BASIC :)

    2. Re:Registers versus Stacks by chromatic · · Score: 4, Informative

      Parrot's register scheme really does help, as do PMCs, which allow much better polymorphism and much better extendability than Perl 5's built-in ADTs. Of course, the JIT and scary goto core don't hurt op execution and dispatch either.

      I didn't mention that I prefer PIR so as not to confuse people, but you're right -- I much prefer writing for IMCC than for raw Parrot. Thankfully, having to care about the distinction mostly went away a long time ago.

  6. Ex Parrot by complete+loony · · Score: 4, Funny
    What? not a single monty python parrot sketch quote yet?
    Well, I'll soon fix that then.
    'E's not pinin'! 'E's passed on! This parrot is no more! He has ceased to be! 'E's expired and gone to meet 'is maker!
    'E's a stiff! Bereft of life, 'e rests in peace! If you hadn't nailed 'im to the perch 'e'd be pushing up the daisies!
    'Is metabolic processes are now 'istory! 'E's off the twig!
    'E's kicked the bucket, 'e's shuffled off 'is mortal coil, run down the curtain and joined the bleedin' choir invisibile!!

    THIS IS AN EX-PARROT!!

    --
    09F91102 no, 455FE104 nope, F190A1E8 uh-uh, 7A5F8A09 that's not it, C87294CE no. Ah! 452F6E403CDF10714E41DFAA257D313F.
  7. No, it was slower! by Bazzargh · · Score: 3, Informative

    In fact, in the presentation on IronPython at OSCON, they also did the Pie-thon benchmark and IronPython WAS SLOWER than CPython. See the presentation. IP was 70% faster than CPython on the PyStone benchmark, which was what's been written about in the past, but on the Pie-thon benchmark, it came out about 4% slower (slides 24, 25). While IronPython was faster on most of the individual bits of the benchmark, he would have been pied in the face as well.

    Its interesting to do a head-to-head comparison of the benchmarks Parrot completed (speedups are relative to CPython):

    b1: IronPython 2.1x faster, Parrot 1.2x faster
    b2: IP same speed, Parrot 3x faster
    b3: IP 1.5x faster, Parrot 2.1x slower
    b6: IP 1.2x faster, Parrot 1.5x faster

    Score: 2 each. Both authors claim they can improve their benchmarks significantly yet, but you have to feel it will be easier for Dan as he's optimising the VM itself, Jim Hugunin can only optimize his IL output for an existing VM.

  8. Parrot is already faster than IronPython... by davegaramond · · Score: 1

    ...though only for tests that Parrot can implement right now. See http://lambda-the-ultimate.org/node/view/141

  9. Type inference (was Re:No chance in hell) by Eivind+Eklund · · Score: 3, Insightful
    Moderators, PLEASE DO NOT MODERATE INSIGHTFUL UNLESS YOU KNOW THE SUBJECT AREA! The text quoted below (parent of this article) is full of simplistic (and wrong) assumptions, and do NOT deserve an "Insightful".

    These languages make certain assumptions about typing and binding that Python and Perl do not. Additionally, Java's class structure is much *much* more time-efficient (though I rather like it less) than Python's memory-efficient proto-based object structure. It's the nature of the languages. It's why they're SCRIPTING languages. They traded speed for ease of coding. Which is just fine. But don't oversell them, you just look foolish.

    Having looked reasonably deeply at the type inference space, this comment seems wrong to me. The division between "scripting languages" and "compiled languages" is superficial. The idea that doing type declarations etc makes a crucial difference is superficial. And the idea that a class is implemented the same way in the compiled code as in the executed code - that's extremely superficial.

    The static (visible, programming level) declarations of type information in Java/C++/etc makes it much easier to write a compiler that generates reasonably fast code. You just follow the type specifications, leave all abstract types as the abstract types, and use a doubly indirected jump table to resolve abstract methods.

    I've seen a non-optimizing C compiler done in three days of intense work by one programmer - and the inheritance/object/abstract methods addition here is fairly trivial.

    Similarly, a simple interpreter is easy to write. I've done one in a day for a simple Lisp dialect. And yeah, they're slow.

    However, this stuff is 1950s technology. FORTRAN came in 1956 (with an amazing optimizing compiler that competed with hand-written assembly), Lisp with an interpreter in 1958-1959 (depending a bit on how you interpret the history). What's interesting today is what we can do with type inference, constant propagation, partial evaluation, memory and cache use optimization, etc. And then the picture changes.

    To be able to handle abstract types effectively, you need to do type inference to find out what actual method will be called by each abstract method call, in order to be able to do partial evaluation and constant propagation through the methods. And - guess what - that's the same stuff you need to do for all methods and variable lookups in a fully dynamic language.

    In other words: The same problem is there for compiler writers, and has to be solved for a fast compiler. You get SOME extra information from the type declarations, but this information is usually the same you would get for the first pass or three of the type inference engine.

    So, for good compiling/execution of Java/C#, I would start doing speculative execution with partially evaluated expressions taking the place of variables in my execution path, resolving these to constants when I can. Different code prefixes (relevant system state parts) result in re-evaluation of the pseudo method call, noting if this makes a difference in evaluation, and either registering the prefix on a new resolution block or adding it to an old resolution block. When all resolution blocks have become non-changing (no more information is being aquired through partial evaluation), I'd stop the partial evaluation and do (virtual machine) code generation.

    For good compiling/execution of Ruby/Python/Perl, I would start doing speculative execution with partially evaluated expressions taking the place of variables in my execution path, resolving these to constants when I can. Different code prefixes (relevant system state parts) result in re-evaluation of the pseudo method call, noting if this makes a difference in evaluation, and either registering the prefix on a new resolution block or adding it to an old resolution block. When all resolution blocks have become non-changing (no more information is being aquired through partial ev

    --
    Doubting the existence of evolution is like doubting the existence of China: It just shows that you're uninformed.
    1. Re:Type inference (was Re:No chance in hell) by Anonymous Coward · · Score: 1, Insightful
      This astonishingly understates the difficulty in dealing with runtime typing and binding. Consider the function:
      func foo(x) {return bar(x) + 3;}
      So... what type is x? An int? A string? A stream? You can't tell because it depends on what's passed to bar. If bar's around, you could use this to infer the type of x for foo. But for many such languages, bar is loaded at runtime *and* in some of them, the type of x passed into bar can change. Compiler researchers have been arguing for a variety of runtime analysis tools to determine the type of objects and perform optimization appropriately; but I've not seen much come of it. Because it's really really hard to do.

      But you didn't even address the grandparent's more salient point: Python uses a proto-based object model. These things are cool. But they're slow. I know of four other languages with a proto model: Self, JavaScript, NewtonScript, and Snarf (a Lisp add-on). The most efficient implementation of a proto-based model was probably NewtonScript, complete with certain caching mechanisms to deal with its essential problem, which is that it's O(slots) to look up a slot value, rather than O(1) in Java. But you can only go so far, particularly if slots are changed a lot. Proto models are a classic example of trading speed for size. They're exceptionally memory efficient, but they're slow.

      The grandparent knew exactly what he was talking about, and you're just tossing out promises which have been made since the '70s. Let's get serious here.

    2. Re:Type inference (was Re:No chance in hell) by Eivind+Eklund · · Score: 1
      It IS fairly hard to do, but there has come some things of it. You can look at e.g. Sun Microsystems Laboratories Technical Report 96-52 (SMLI TR-96-52), "Concrete Type Inference: Delivering Object-Oriented Applications" by Ole Agesen for examples of what has been done around Self (to take an example of type inference done around proto-based languages).

      Another form of type "inference" done at run time is type feedback; that also gives reasonable performance, and IMO much has come of it, it just isn't beeing made a lot fo noise around it, because it is fairly complex and the performance "mainstream" still do type declarations.

      The complete type inference problem for proto based languages is NP-complete, but solving limited versions of this problem gives interesting results. I noted this in the first post I did.

      The approach I described is a variant of the Vitek, Horspool and Uhl data flow system described in Vitek, J., N. Horspool, and J. S. Uhl. Compile-Time Analysis of Object-Oriented Programs. In Proceedings of CC'92, 4'th International Conference on Compiler Construction, p. 237-250, Paderborn, Germany, October 1992. Springer-Verlag (LNCS 641).

      Talking about the cost of looking up slots assume you are not doing type inference or anything like it. My basic premise was that the original poster (great grandparent of this post) was ignoring type inference and partial evluation, and that it was assuming that the structure of code generated was equal to the code structure in the input program. The parent of this post keep assuming that the same structure has to be used.

      Dynamic loading is relevant if we assume that as a property of the language - it do naturally block inference before the code is loaded. I do not consider dynamically loading the code to be executed at run time as a feature of a language; that's a feature of an implementation, and may or may not be relevant for a particular use. For high performance programs, I consider the whole program compilation (or almost whole program compilation, where defined aspects are left for run time loading - see Zoran Budimlic's "Compiling Java For High Performance and the Internet) as the only relevant case.

      I've not been able to find relevant performance comparisons for the different cases right now; the closest was the high performance Java paper above, showing that it was necessary to do specialization to get Java to compile to within an order of magnititude of FORTRAN, but I found no real data. I know that compiler writers are silently doing type inference from having searched up this previously, but I cannot find the references right now. They've been limited to a sentence or two in the manuals of various compilers and anecdotes from people working on commercial compilers.

      Eivind.

      --
      Doubting the existence of evolution is like doubting the existence of China: It just shows that you're uninformed.
  10. Excuses, excuses by truth_revealed · · Score: 2, Informative

    The Parrot team had ONE YEAR to complete the Pie-thon task - the challenge was made at OSCON 2003 for crying out loud! Meanwhile in less time than that the IronPython guy wrote a complete (and fast) Python to CLR translator by HIMSELF. Sorry, but the Parrot team's "dog ate my laptop" excuses don't hold water.

    1. Re:Excuses, excuses by Elian · · Score: 2, Informative

      No, I had six months -- the benchmark wasn't written until early January this year, at which point I had more important things to do and put it off. For too long as it turned out, since I didn't even take a serious look at it until late May.

      This was never a "Python people" vs "Parrot people" bet. It was personal, between Guido and me, and I didn't factor in enough time to allow for delays, so I lost.

    2. Re:Excuses, excuses by truth_revealed · · Score: 1

      The python challenge scripts were available for only 6 months, but you had a full year to write a python bytecode interpreter. Anyway, Leo almost got the scripts working, to his credit.