Reflections on a decade of MoarVM, a runtime for the Raku programming language
summary
MoarVM is a C register‑based VM for Raku implemented with NQP that evolves from a simple bytecode interpreter into a runtime with type specialization, deoptimization, multi‑level inlining, on‑stack replacement, a JIT, and basic escape analysis; it uses a generational parallel but stop‑the‑world GC and a separate specializer thread fed by flat logs. Hot VM primitives are removed in favor of a single generalized dispatch mechanism with user‑space dispatchers and resumable dispatch to implement call‑next semantics; specialization gives the largest speedups, JIT helps tight code, and megamorphic sites can be up to 20× slower.
AI-written summary · about
chapters (47)
- 0:00MoarVM is...
- 2:26How I got involved
- 2:54Perl 6
- 3:53Dynamic language, but...
- 4:32Operators are multis
- 6:06Meta-programming
- 6:49Grammars
- 7:27Raku eats itself
- 8:41Sounds idyllic...
- 9:35Parrot
- 12:25A language for MoarVM
- 13:22Why register-based?
- 14:36Register VM downsides
- 16:57Coping with C and a GC
- 18:02Object system
- 23:35Scarce resources
- 25:06Getting started
- 26:37Optimizations
- 27:38Then crash and burn...
- 28:14Deoptimization
- 28:57Statistics will do
- 29:30Specialization linking
- 30:06Inlining
- 31:43Machine code
- 31:57What helps most?
- 33:13Complexity? Bugs!
- 33:26Triggering bugs
- 35:05Optimization takes time
- 35:42Specializer thread
- 38:53Mono, poly, mega
- 39:43Broken assumptions
- 40:40Example: assignment
- 42:01Speedup Speed hump
- 43:49It's all about dispatch
- 44:40Take it all the way
- 45:07One opcode
- 45:33Dispatch terminals
- 46:39Userspace dispatchers
- 47:56Dispatch program
- 50:44The problem
- 51:11Resumable dispatchers
- 51:39The resume callback
- 52:08Record phase
- 53:21Run phase
- 54:17A big improvement
- 54:56No silver bullet
- 55:29Also: longer warm-up
related talks
39mA R4RS Compliant REPL in 8Kb
57mJava on Elbrus
54mWhat Lies Beneath
36mDynamic VM Memory Resizing daemon (vmrd)
51mAccelerating performance of Java applications on Arm64
45mRV: where are we?
33mParallel Processors: Past & Future Connections Between LLMs and OS Kernels.
39mJava on ARM. Theory, Applications, and Workloads
