Day 49: Compiled Mandelbrot.

autrijus on 2005-03-21T18:07:58

This afternoon I've thrown together a mandelbrot example for the Pugs compiler (to haskell) backend work. It looks like this Haskell code; and here is the original Pugs AST.

Here's the benchmark numbers:

Pugs Interpreted:   77.29 seconds 477k memory
PugsCC Unoptimized: 01.35 seconds 476k memory
PugsCC Optimized:   00.39 seconds 455k memory
Perl 5:             00.14 seconds 362k memory

Note that the mandel.hs above is still using the doubly-boxed Val type, and the ultra-slow op1/op2 dispatch, just so we can reuse all Prim.hs code and guarantee to have the same semantics. Hence, there is a large room of improvement. But I think it's good for a two-hour hack. :-)

For the next step, I'm hanging out in irc.perl.org #parrot now, learning from Coke, Nicholas, chip, bernhard and other helpful people about how to model a Parrot AST in Haskell, as Compile/Parrot.hs in Pugs. The plan is to use Template Haskell to compile Pugs AST into a Haskell program that, when executed, produces PIR code. See One-Day Compilers for the general technique.

So I plan to start from Python and Cola's AST->PIR translators and work from there; we'll see if I can get one working this week before YAPC::Taipei.

In other news, nothingmuch hacked a whole day on the currying .assuming() code, radically refactoring the underlying VSub structure to contain prebound parameters, as well as refactoring bindings to use Val instead of Exp, to allow both lazy and strict evaluation modes. His enthusiasm and the amazing ability to grok the non-commented evaluator core is really, really moving to see. Way to go, יובל!

Stevan, the test squad leader and another tirelessly helpful soul, listed a large set of TODOs for us to work on before we reach 6.2.0. Development has never been so joyful for me, with this thourough test-driven plans, clear implementable goals, so I can code with abandon without fearing regressions. Soon, with the test cataloger and backlinker, we'll have a nice HTML page for interested people to see our status at a glance. Wonderful.

On the documentation front, ingy and mugwump has finished most of Kwid to DOM to HTML formatting stuff, and got lots of DOM semantics done. I am really looking forward to their arrival on 23th, so we can get Pugs's object metamodel going and start moving toward 6.2.0.

Randal Schwartz reported that CPAN.pm and CPANPLUS could not detect that there is a newer version of Pugs on CPAN. The reason turns out to be that MakeMaker and CPAN::Version has different ideas about v-string versions, so I whipped up some Module::Install magic to compensate the MakeMaker bug. So Pugs 6.0.13 should be appropriately upgradable.

I think that's about it for today. Soon I'd need to work on my YAPC::Taipei talk. Hopefully I will have a Perl 6 -> Parrot compiler for the audience to see...


Computer Language Shootout

Greg Buchholz on 2005-03-21T21:41:49

Excellent. Looks like pugs is starting to give perl5 a run for its money. Although I suppose we should wait at least a little while longer before submitting entries to The Computer Language Shootout.