January report of the Raku Development Grant of Jonathan Worthington
Fri, 19-Feb-2021 by
Happy to announce that Jonathan was able to resume work on his Raku Development Grant.
Here is his report.
In January, I at last felt in shape to get back to the new dispatch mechanism. The key remaining piece of the mechanism is *dispatch resumption* - a general term I'm using for a range of situations where we start doing some kind of dispatch, and may continue it later. For example:
* When we call a method, we might later use `callsame` or similar in order to call a method in the base class (strictly, given multiple inheritance, the next method in the method resolution order)
* When we use `wrap`, we also use `callsame` to call the wrapped code (and there may be any number of wrappers)
* When we call a multi candidate, we can also use `callsame` to defer to the next best one
* When we have a `proto` `sub` or `method` with a body, we need to run that body before we proceed with the multi-dispatch
* Today, when we have a multi-dispatch with `where` clauses or unpacks, we need to do a test bind of the signature to see if the candidate is valid, followed by doing the invocation. This creates duplicate work. A better way would be to just try calling the candidate and having a way to treat a failure in parameter binding as a dispatch resumption, at which point we'd just continue with the next candidate.
Having an intuition that these can be neatly handled as cases of the same thing is rather easier, however, than coming up with a design to make it happen! Last year, before I had to take a break from my work on this, I had a number of false starts: designs that were partly right, and gave me some things to implement, but that all ran into problems.
Finally, I believe I've got a design that holds up. While that was still a quite theoretical claim at the end of January, I'm writing this report mid-February, by which point I've got a significant amount of the desgin implemented and working. Despite the fact that the specializer has not yet learned about this aspect of the new dispatch mechanism, I'm still seeing speedups of a factor of about 7 in a `callsame` to parent `method` benchmark (with 4 levels of inheritance), and a factor of 10 in a benchmark involving a subroutine with a single wrapper. I had planned to accompany this report with a link to a blog post with further technical details and the benchmarks; unfortunately, that's been delayed thanks to an injured arm (which I hope is now on the mend, although I should still keep my keyboard time down a bit for the days to come).
15:59 Work on dispatch resumption in new dispatch mechanism
00:17 Code review
Total time worked: 16 hours 16 minutes
Ps: In December 2020, Jonathan worked 1 hour, 42 minutes:
"In December I worked on a performance issue with native shaped arrays, which made indexing of them significantly slower than with unshaped arrays."
Experience for the Raku developer, including composing support, live identification of blunders in the code, code route, a coordinated test sprinter, troubleshooting, and that's just the beginning. https://www.branex.com/custom-software-development/