Recent progress

I've made lots of progress recently on both mod_parrot and mod_perl6. Here's what's been happening.


The most significant addition to mod_parrot is the ability to specify which Apache request phases an HLL module is interested in servicing. This saves a lot of overhead during each phase of a request. For example, mod_perl6 is interested in every phase, since it's designed to hook into every part of the request phase. PHP on the other hand, only serves content, and is thus only interested in the response phase. The whole thing was extremely difficult to implement and debug, but it's done and I'm happy not to have to look at it again!

One gaping hole in mod_parrot was the inability to read the HTTP request body, which is how POST data is sent to the server. That is no longer a problem, as I was able to implement Apache; Many thanks to mod_perl2, for both helping me understand and providing code for me to adapt.

Other goodies include methods for manipulating headers, better error handling in places, and general code cleanup.


I love writing mod_perl6. It's written in, well, Perl 6! I'll admit it does get frustrating at times -- I still run into a lot of unimplemented features or bugs in Rakudo, but I can usually get a fix fairly quickly or work around it with a little PIR scaffolding. Eventually the only PIR we'll have is the module bootstrapping code, which is minimal. Anyway, onto the details...

I've been putting a lot of effort into ModPerl6::Registry, as I'd like to get November running as a registry app. That said, I added support for more CGI environment variables, including HTTP_COOKIE, CONTENT_LENGTH, and even a MODPERL6 variable so scripts can detect if they're running under mod_perl6. I would have loved to get POST data tied to STDIN, but the IO support just isn't there yet in Parrot (shouldn't be long though). The last remaining headache was parsing response headers from STDOUT, but I believe this will require some output filter magic that I'm not ready to tackle yet. So as it stands now, November does run as a registry script, but it needs a few patches here and there, and its CGI implementation needs some mod_perl6 awareness. So it's close, but no cigar.

Probably the most useful feature I implemented was module preloading with Perl6Module. Due to the current parsing overhead of Rakudo, using Perl6Module can shave a large chunk of time off the initial request to a handler, and save memory as well.

At my request (more like begging), Jonathan and Patrick added support to Rakudo for passing flattened arrays to subroutines, and having their elements mapped to arguments. This is the behavior we're used to in Perl 5, and I needed it for implementing different handler forms. So now we have regular handlers, where we specify the module name, and mod_perl6 calls the handler subroutine. But now we also have literal handlers, where you can specify a subroutine name other than handler. This is useful when you want a single module to handle multiple phases. And we also have method handlers (Perrin asked me about this at YAPC), where you provide a class name, and the handler is called as a method. This allows your handler to take advantage of inheritance and other OO goodies.

With all of these new features, the code is growing, and it's taking longer and longer to start and restart Apache for testing. I tried precompiling to PIR, and guess what -- it shaved about 90% off the startup time! Needless to say, I added support for that into the bootstrapping code, but you'll have to precompile it manually until I break the project out from mod_parrot and create a proper Makefile for it.

Next steps

I'm extremely pleased with the progress I've made over the past few months, and I owe many thanks to everyone on #parrot and #perl6 for implementing functionality and fixing bugs in Parrot and Rakudo. I'm very close to a release of mod_parrot (0.5). Once that is complete I'll break off mod_perl6 into a separate project. I'd also like to have a more formal roadmap for each, which was difficult in the past due to the immaturity of Parrot and Rakudo at the time. But we don't really have that problem anymore. Fun times ahead!

Very encouraging progress Jeff.