2014.28: Moar jit, string overhaul, metaoperators, …

Even though the previous post was a bit late and so this one covers a few days less, there’s interesting things to report. This week, raiph sent me a little summary of IRC activity again, which made it much easier for me. So thanks!

And now let’s see about those developments:

  • hoelzro has continued work on the pod documentation attaching to entities (methods, classes, variables, …)
  • Will Coleda worked on cleaning up our spectest suite a bunch.
  • brrt has continued work on the JIT, namely making invocations work (both the spesh-improved “fast” invocation and the regular “slow” invocation).
  • There is now also a log that shows what opcodes end up being jitted and which opcodes cause the JIT to bail out due to NYI or other reasons.
  • Using this log, brrt concentrated on a bunch of opcodes that commonly cause bails.
  • Even I got some work in this week, namely having been inspired to hack on the JIT a bit myself; a bunch of ops can be compiled to regular C function calls, and those are sufficiently easy to add. I’ve added support for:
    • checkarity (which is responsible for giving run-time errors for wrong numbers of arguments if we couldn’t determine that at compile time)
    • push_o, pop_o, shift_o and unshift_o (to access lists and such)
    • atpos_o (getting an object in a list by index)
    • getattr_s (accessing a named attribute of an object; with help from brrt).
  • Additionally, jnthn pointed out that deconts on containers that are quite simple (just a pointer indirection) can be spesh’d to look exactly like a spesh’d attribute access, so I was able to add support to spesh to simplify some deconts (which is an operation that used to cause the jit to bail out extremely often).
  • The top ops causing the JIT to bail during the compilation of CORE.setting are now:
    • “graphs_s” (which seems to be in every piece of code that follows “getattr_s” + “flattenropes”)
    • “ifnonnull” (100% of the “atpos_o” bails turned into “ifnonnull” bails)
    • param_rp_o (grab a required positional parameter)
    • newlexotic (related to exception handling)
    • the decont ops that were not spesh’d away.
  • Sadly, MoarVM’s JIT compiler isn’t invoked at all in the case of On-Stack-Replacement optimized code, so none of our current benchmarks will show any change between JIT and no-JIT.
  • jnthn has started on the long-awaited rewrite of MoarVM’s string handling. Here’s a benchmark from jnthn’s machine comparing last month’s release of MoarVM, the strref branch of MoarVM and last year’s rakudo-parrot. (so no JIT yet). Across the board there’s improvements, but the most important improvement can be seen in the benchmarks that have “concat” in their names. These are the ones that concatenate strings.
  • jnthn greatly improved the metaoperator parsing in rakudo. The parser used to barf when it saw rather unwieldy operators with disambiguating brackets in them and set operations and such, for example (|)= or metaops with reductions like [[*]]=.
  • jnthn also merged the “lex2loc” branch that allows the Optimizer to turn lexical variables into locals if we can prove that they’re not accessed outside the frame they’re in. All backends benefit from this.
  • psch finished the implementation of the translate operator “tr///” and its return value.
  • thanks to japhb, more perl6-bench improvements landed.
  • A whole bunch of work has been put into improving the POD to HTML rendering by Mouq, lue and atroxaper, like the Pod::SAX, Pod::Walker, and an HTML renderer based on both of these modules.
  • retupmoca added a module for interfacing with RabbitMQ to the ecosystem, called Net::AMQP.
  • lizmat worked some more on S22 and the related tests and did some more discussion about details with the community.
  • lizmat and retupmoca fixed problems for Supplies that are .tap’d multiple times.
  • masak added a module Data::Pretty that will give common things you might want to “say” a friendlier output.
  • sergot posted about adding both a high level and a low level wrapper for OpenSSL on his blog.

And if you’re interested in getting into Perl 6 Module Development, you could adopt bbkr’s MongoDB related modules BSON and MongoDB.

The next releases are going to happen soon-ish. On Thursday, MoarVM is going to be released and the NQP + Rakudo release is going to follow this week, too.

Thank you for reading and may your week be filled with adorable kitties (or something equivalently cuddly, if you’re allergic).

2014.27½: A boat load of stuff, pointer arithmetic and casting.

Hey there! I’ve been a bit busier and distracted than usual this monday and tuesday. Sadly, I can’t really write the posts on sunday night and publish them when I get out of bed, as many nice things usually happen between sunday evening and monday noon :) Anyway, raiph combed through the IRC logs for me and collected a whole bunch of things. Here’s my rendition of the recent happenings, including up to today, as I’m running so late:

  • lizmat led the discussion about the behavior of writing “my %h = { … }”, which is now considered assigning an itemized hash to a hash variable and gives a deprecation warning. Programmers might assume this would flatten the right hand side into the hash, but we found that behavior too magical. Thus, lizmat took care of that.
  • psch has been working (for a bit longer than just this past week, actually) on patches to teach rakudo to properly work with tr///, the “translation” operator. It’s supposed to return the number of characters changed in the source string, which was the most complicated part so far, it seems.
  • FROGGS taught all backends to do pointer arithmetic on CPointer repr’d things, allowing NativeCall to handle array-like things better.
  • FROGGS and sergot also implemented “NativeCast” for the NativeCall module, allowing a CPointer to be cast to any type we know. Apart from legit use cases, this allows some scary, scary stuff to be done :) (see also)
  • The above work is an important stepping stone towards proper TLS support as well as supporting function pointers (for an OpenGL implementation, for example, when you want to have GL extensions)
    • Function Pointers need a bit more work in the perl6 Grammar (actually the Actions) so that we have proper type annotations for &vars (like my &funcptr:(int, int –> int) or something)
  • lizmat implemented and then reverted the “is cached” trait on methods, which is a bit harder than doing it for subs, because it has to factor in the “self”, as well. It’s not yet clear what the semantics are supposed to be.
  • lizmat has also continued working dilligently on the S11 and S22 things, among others the CompUnitRepo classes. I saw FROGGS do a few things in this area, too.
  • masak and krunen did a little “ping-pong programming session” to implement “emmabot”, a bot that should report on the daily ecosystem and Rakudo Star module testing results. Here’s the section of the irclog and here’s the repository for the bot. I didn’t pay close attention to the conversation, but it might be a good example of how to do Behavior Driven Development :)
  • Speaking of the daily ecosystem module testing results, a result page now lives on one of our servers and can be reached here, thanks to moritz, coke and colomon.
  • hoelzro invested a bunch of time into making the handling of #| (that is, attaching pod comments to variables, methods, classes, subs, …) to spec in rakudo and the test suite. Turned out to be quite a bit hairier than it looks from afar!
  • dwarring continued to improve our test coverage of the advent calendar posts.
  • japhb landed more improvements to perl6-bench, including extracting a bunch of smaller benchmarks from rc-forest-fire to help figure out why rakudo is so slow at it.
    • In doing so, we found out that rakudo easily beats perl5 at Big Rational Number arithmetic. Pretty neat!
  • jnthn continued his usual work: stability and performance. Among other things, rakudo now turns more lexicals into local variables if it can and variables gained a new scope (“typevar”) that is interesting for optimizing roles and such.
  • jnthn helped japhb figure out what changes are needed to get perl6-bench to run well on windows. Here’s a benchmark result from his machine.
  • jnthn has made MoarVM’s bytecode specializer throw away guards that the specialized code ends up not relying upon. This reduces the number of times we deoptimize unnecessarily.
  • A few fun things on RosettaCode: TimToady’s “draw a clock” implementation with braille-based graphics and sml’s parser for the Multiple Dwelling Problem.
  • tadzik tried out MoarVM on his phone. Sadly, cross-compiling the MoarVM bytecode isn’t as trivial as it ought to be, as it contains file paths that would need fixing up…
  • Mouq is working on a Pod::Walker module to make creating Pod-To-* converters easier. In order to test it, he’s also refactoring Pod::To::HTML to be based upon it.
  • atroxpaper is working on a different Pod Walker, namely Pod::SAX. It will provide a stream-like/callback-like API to processing Pod files.
  • retupmoca fixed up the ecosystem to point IRC::Utils, Date::WorkdayCalendar, TestML and YAML at forked repositories on github that had pull requests open for longer than a month.
  • zengargoyle built a module for fortune files, grondilu started work on a module for “chess related stuff”.
  • Coke dilligently made sure everything’s all right with the daily test runs. For example, att one point, rakudo.parrot had failed 1800 spectests (due to mostly a single problem).
  • JimmyZ updated MoarVM’s packaged uthash to the newest version.

Here’s an update on the GSoC stuff:

  • brrt recently blogged about his progress and has been working mostly on refactoring the code base and supporting invocation in the jit since then.
  • sergot has started working on OpenSSL related things. The repositories can be found on his github.
  • Unfortunately I have either not heard from the other projects or forgotten what I’ve heard, but I do recall that all our students have passed the mid-term evaluations!

Apologies again for the much belated post. Hope y’all have a nice week :)

Update: a few inaccuracies were fixed.

2014.26: On-Stack-Replacement, stability, …

Well, let’s see here …

  • On-Stack-Replacement was merged by jnthn into master and seems pretty stable. It lets the bytecode specializer (and later the JIT compiler) kick in even when there are no invocations involved, like in a loop with many iterations.
  • There’s also improvements to inlining, especially stronger return handler elimination inside Rakudo.
  • Today, jnthn put a bunch of work into making MoarVM’s multithreading and async I/O stuff more robust. We’re regularly torture-testing a very simple asynchronous server using wrk (a tool like ab) to find race conditions and such. It’s not perfectly stable, but getting better.
  • Lizmat also made some async/threads fixes.
  • The JIT compiler for MoarVM learned how to handle lexicals (bindlex and getlex), simple attribute access for objects and “World Values” (most commonly compile-time constants and classes/subs)
  • A talk by jnthn on garbage collectors in general and the garbage collector of MoarVM in particular has made it onto the public ‘net. You can watch it on InfoQ.
  • There’s a few new benchmarks in the perl6-bench repository. As opposed to the big chunk of microbenchmarks we’ve had so far, these are a bit bigger. They were taken from RosettaCode.
  • Japhb also started working on a “history” comparison type for perl6-bench, but it doesn’t have an output functionality for html graphs.
  • Here’s a couple of days old benchmark run that compares rakudo and nqp with and without a recent fix to OSR and inlining to a 2014.06 released rakudo/nqp as well as perl5. This doesn’t include the JIT, unfortunately, and the difference is only really noticable in a few of the graphs (damn you, log-log scale!). I guess for next week I ought to make a somewhat more comprehensive benchmark with older versions and maybe even with the JIT.
  • FROGGS’ panda version with CPAN support can now extract .tar.gz files it pulls from the ‘net!
  • Someone added a bunch of examples to RosettaCode, but I couldn’t easily figure out which ones. But since RosettaCode is constantly growing anyway, it’s always a good time to check out what’s new!

I’m already looking forward to next week’s changes, there’s lots of stuff that still needs doing. For example, we’ve been avoiding the string (actually rope) rewrite for a long time and MoarVM’s performance for things like concatenation has suffered greatly for it.

Anyway, that’s it for now. I wish you a pleasant week :)

2014.25: optimizations, more CPAN, more GSoC, YAPC::NA, and a release.

I’m sorry for keeping you waiting yet again; the GulaschProgrammierNacht 14 kept me busy and after it was done I was as tired as I haven’t been for a long time ;)

Here’s what’s been going on:

  • FROGGS is continuously working on the CPAN support for panda. His code can query and fetch distributions from CPAN already, and decompress the .gz part of the .tar.gz, but the Archive::Tar module still needs to be finished.
  • jnthn added the very first steps towards an On-Stack-Replacement operation. OSR is required to optimize hot for loops, for example. Usually, we trigger optimization when a function is called often enough, but with such a for loop, all we do is jump back over the same code over and over. Instead of “jump to this different function”, OSR has to directly jump over into optimized bytecode (or jitted bytecode) and make sure variables on the stack and exception handlers and all those things are kept in order.
  • The YAPC::NA (“Yet Another Perl Conference, North America”) is currently happening. As far as I’ve heard, there are only two Perl 6 related talks. Find the complete list of talks on the official website. A bunch of videos have already been uploaded to youtube at the time of writing. Find them in the YAPC NA Youtube Account. The Perl Six Youtube account also has a playlist of english perl 6 related talks that contains the YAPC::NA talks.
  • lizmat, with a bit of help from jnthn, optimized say and note if they are called with a single Str argument.
  • lizmat also worked more on the CompUnitRepo stuff in Rakudo as well as CPAN, implementing more and more stuff from S11.
  • lizmat implemented an :initial argument for my zip_latest Supply combinator. It helps in use cases where you want to get a combination of values from all supplies even if not all supplies have supplied their very first value yet.
  • jnthn fixed the behavior of the “item” sub. the “item” method has always been correct, however.
  • FROGGS implemented subbuf-rw and the “a” and “Z” directives to the unpack method. I’m guessing this is in order to satisfy the needs of Archive::Tar.
  • we updated parrot’s required revision to version 6.5.0, giving us nice things like unicode database fixes and faster core PMC classes.
  • carbin fixed the default file mode in MoarVM’s file ops to be 0666.
  • Mouq, smls and teodozjan did a bunch of work on doc.perl6.org; Among others, they implemented a design overhaul that had been made by another member of the community some time ago. It’s easier to find one’s way around the docs now and there’s more content!
  • japhb added a bunch of new bigger benchmarks to perl6-bench and also started implementing “history” comparisons among other things. Those show the timings of single benchmarks in different revisions of a backend as one line.
  • dwarring fixed and created more tests for the advent calendar articles.
  • masak wrote up an interesting article and with a bunch of code on his blog. It discusses and solves a problem called “Boxes and Pebbles”.
  • softmoth improved the look of modules.perl6.org.
  • bebus reported being able to run Perl 6 on a Nexus 4 android phone!

Another thing that’s happened is that the Rakudo 2014.06 compiler release got out. There’s the Rakudo changelog, the NQP changelog and the MoarVM changelog. The Parrot changelog can be found on the Parrot website, which also contains the latest progress report of the Parrot GSoC student.

Here’s a bit of an update for the GSoC projects:

  • This week, mentors are submitting evaluations to Google for their students. I expect all three students to be allowed to continue; I’ve personally been pleased with their work!
  • brrt just pushed support for passing and returning floating point values to and from methods and then added some arithmetic operations. I didn’t run tests myself, but the fibonacci example supposedly runs 2.5x faster with the JIT than without. A pretty good start!
  • filip sergot built a binary “http-download” that is a very thin frontend to HTTP::UserAgent that can handle encodings like the chunked transfer encoding. Of course you can do your own requests rather than just downloads with that module.

There’s also a low-hanging fruit for you to try to fix:

  • MoarVM can be compiled with “computed goto” or without. On GCC, we could turn it on unconditionally and it’d result in a very nice speed boost, but our build system (more correctly: MoarVM’s Configure.pl) doesn’t do that yet. Should be fairly easy to fix and be quite helpful. EDIT: FROGGS did this just now.

Special thanks to raiph who pointed out a whole bunch of items for this week’s post that I’d have otherwise missed! Hope you’ll have a nice rest-of-week :)

- Timo

2014.24: Inlining, some more JIT, a bit of gtk and cairo.

Wow, this week I’ve even done some stuff! I’ven’t been active in the source code for a while, so it felt quite refreshing. Here’s all (well, at least some of) the nice things that have turned up over the last 6 days:

  • jnthn has merged the “inline” branch of MoarVM that adds the ability to inline simple bytecode segments into their caller’s bytecode, thus getting rid of a nice chunk of invocation cost. Sadly, it currently bails out if it sees exception handlers or “return” handlers, which is extremely common in actual Perl 6 code. Thus, the improvements are mostly visible in NQP code.
  • I added a few more methods to the cairo binding and started on the GtkDrawingArea class for the gtk3 binding. There’s a whole lot of stuff involved before enough stuff is in place to make cairo-based animations work well.
  • I also implemented a Supply combinator called “zip-latest”. It will generate a tuple (or apply your custom sub) every time a new value comes in from any of the supplies, as opposed to the “zip” combinator that waits for all Supplies to have a new value available.
  • lizmat did a whole bunch of commits related to CompUnitRepo and friends. It’ll be exciting to see the whole potential of the infrastructure used, for example applications bundled with all their dependencies in a single executable file and other kinds of things.
  • brrt continued his GSoC work on the MoarVM Just In Time Compiler. The current piece of code that’s being used as an example is running the following subroutine in a loop:
    sub foo() {
        nqp::say("OH HAI");
        return 12 - 6;
    }

    The JIT compiler turns the whole function directly into runnable machine code, which at the very least eliminates the interpreter overhead.

  • Chirag Agrawal and Reini Urban have pushed more work in their optimization efforts for write barriers. Reini reports a 2-4% performance improvement in the NQP test suite after annotating all the 6model classes correctly. This work is part of the  Parrot 6.5.0 release (planned for tomorrow). In addition, rakudo-parrot is going to pass all spectests again (when a pull request is applied). Cool stuff!
  • dwarring could be considered on a roll, as he’s continuously writing spectests for the Perl 6 Advent Calendar of the past years :)
  • Kamil Kułaga added a utility program for Lacuna Expanse written in Perl 6 to the ecosystem.
  • Michal Jurosz added a simple templating library for Perl 6 to the ecosystem.

That’s it from me for this week’s post. I hope your week is productive and pleasant :)

2014.23: Beginning of inlining, some GSoC work materializes, DSON encoder/decoder

In order to smooth the transition back to the “every monday” schedule, I decided to write this post on tuesday instead of monday. Here’s some of the things that have happened since last wednesday:

  • Filip Sergot added HTTP::UserAgent (but only ::Simple so far) to the ecosystem.
  • brrt has been working on the MoarVM JIT based on DynASM, but it seems like there’s a problem regarding dynamic register usage in DynASM. Still, with only static registers, a JIT could remove the overhead introduced by decoding and dispatching opcodes in the interpreter, better performance with the CPU cache, …
  • Chirag Agrawal and Reini Urban had been improving parrot s pmc2c and PMCs by removing nested method calls and unneeded write barriers. It doesn t break the rakudo build, but performance measurements are still to be done. PMC write barriers can now also be manually optimized. See this changelog patch for some more details.
  • jnthn has started work on letting MoarVM’s spesh inline code at specialize-time. Currently, NQP won’t start with it, but just looking at the log output shows a few nice opportunities already being considered for inlining.
  • dwarring put more tests into the test suite for the advent calendar posts.
  • donaldh worked on the socket tests for JVM and async socket tests in general.
  • XFix wrote a decoder and encoder for DSON, a very promising data serialization format. It’s derived from JSON::Tiny and re-uses a lot of its code; it’s a nice example for subclassing grammars: Compare the Actions.pm from JSON::Tiny and the Actions.pm from Acme::DSON.
  • the dyncall version included in some of our repositories were causing trouble on FreeBSD. That was worked on.
  • Ulti split off the statistics functions from his BioInfo module into a stats module. It currently has mostly average-related things.
  • FROGGS put all the necessary stuff in place to allow slangs to be written in Pure Perl 6 and is going to modify his v5 module to be written in Perl 6 rather than NQP in the future.
  • Larry Wall added two nice bits to STD.pm: Don’t throw errors about deprecated special variables inside signatures and warn about duplicated characters in character classes. For anybody looking to get into rakudo development, porting these patches to Rakudo would be a very nice low-hanging fruit.

Thank you for your patience. May your week be a pleasant one :)

Belated: 2014.22 (and pieces of 2014.23): Eleven and other stuff.

Hi there,

I’ve been surprisingly busy the last two days and didn’t get to write the weekly yet. Curiously, there wasn’t terribly much to write about anyway. So I’m taking the first few days of this week into account as well, so there’s more exciting stuff. Here goes:

  • lizmat and FROGGS have been working on implementing the new and improved spec S11 about modules and importation and versioning and stuff. That work had been happening in a branch until recently and it’s now on the master branch. I probably ought to write up what cool stuff you can use it for when the next release comes up unless somebody beats me to it.
  • donaldh has improved the IO related pieces of the core setting by removing special cases for different back-ends and partially re-implementing things as nqp ops there.
  • rakudo now honors a RAKUDO_MAX_THREADS environment variable to change the default amount of tasks that should be run at the same time in the ThreadPoolScheduler. This can still be overruled by creating a ThreadPoolScheduler with a specific max_threads, though.
  • jnthn has fixed a bunch of sundry problems: for loops with an explicit or implicit $_ that is marked “rw” used to clobber the outside $_, sub-signature binding (AKA destructuring assignment) used to turn itemized things into lists regardless of provided sigil, and a LAST phaser in a loop used to fire even if the loop didn’t run even once.
  • jnthn has taken up my preliminary work to make MoarVM’s bytecode specializer handle calls with named parameters as well.
  • lizmat has done a bunch of work on $*PERL/$?PERL, $*VM, $*USER, $*DISTRO, and many more.

Other things worth pointing out:

As usual, I hope you’ll have a pleasant rest-of-week :)