The new MoarVM dispatch mechanism is here!
6guts.wordpress.com/2021/09/29/the-new-moarvm...Posted Sep 29, 2021, 9:47 PM UTC
163
Posted Sep 29, 2021, 9:47 PM UTC
For those interested in more articles about this work, see the last few blog posts at https://6guts.wordpress.com/.
The post is not very clear about what's the new mechanism here (it generalizes several runtime-dispatch mechanisms in the MoarVM bytecode; but how?). The linked slides say more, but are written with MoarVM-specialists in mind. Here is what I understood, as someone unfamiliar with MoarVM:
This is what I understood. It looks like a nice idea! It's a generalization of known mechanisms that can cover more language features, while simplifying the overall implementation.
Mild criticisms:
nqp::dispatchwith many strings argument that basically correspond to dispatch-language keywords, but may do wildly different things. I would rather see something that looks more closely like a shallow DSL.Thank you for the extensive comment. :)
Right. The article I posted is about the immediate impact of landing the new mechanism in the production version of the Rakudo compiler. In particular, immediate speedups. As an example, regarding this factorial code benchmark:
jnthn writes:
(The "So there's more to be had" refers to future optimization opportunities he discusses in the article, but the "factor of ten speedup" is one of the immediate impacts.)
Perhaps watching the video will help? I'd say I know relatively little about bytecodes in general and MoarVM in particular, but I found the video very illuminating. The early part of the presentation covers the motivation and challenges. The new mechanism is discussed after that preamble.
I'd say the slides are a mix of high level stuff and nitty gritty details that perhaps only make sense in the context of the spoken presentation. In the slide deck, the part of the presentation that focuses on the new mechanism starts at pages 47/48.
Thanks!
To be clear it was proposed a couple years ago. What's just happened is that the initial work has recently been completed; it passes the 200K unit tests for the compiler; all the unit tests of all publicly shared modules are passing save for a handful that it's been agreed should not block the merge; and some performance regressions have been addressed (it's not all roses); and so it has now landed in the main branch of the Rakudo compiler that is due for a production release in a few weeks.
From the presentation (see, for example, pages 47/48 of the slide deck), I understood it to be, quote, "just":
I interpreted that to mean it was "just" a judiciously designed single new bytecode op/instruction. So I'm surprised at your description of it as a DSL.
Like I said, I didn't interpret it as a DSL. Things like fetching the type of an operand is just another, already existing, opcode. And I was thinking that the adding/removing arguments aspects were also already existing opcodes. But maybe I'm wrong about that and/or about the DSL notion. Perhaps someone more knowledgeable will read this comment and reply to clarify.
That's my understanding.
Right. Because the dispatch opcode is really just another opcode.
Right. That's my understanding too.
I think there are four "commands" built in:
boot-value and boot-constant (overview at pages 50-53 in the slide deck)
boot-code and boot-syscall (overview at pages 74-75 in slide deck)
Again, just reading the slides may not be of much use; consider watching the video corresponding to those slides.
In addition there are "Userspace dispatchers", (discussion starts at slide 77). These are perhaps the most important, though they ultimately always delegate to the four boot-* commands.
That makes sense.
(That said, I doubt that'll happen unless someone other than jnthn decided to build such a DSL. He's just spent a couple years on this work, knows
nqpwell, knows there are a dozen others who are comfortable writing nqp code, and has a lot of other fish to fry.)Anyhow, thanks again for reading the article and commenting, and I hope my reply has been helpful.