Maple Ong

Looking into Peephole Optimizations

I gave this talk at Euruko 2022 in Helsinki, Finland. It was the largest live audience I've spoken to to date! I've reached Keynote Animator status considering the amount of time I spent animating the VM stack for this talk and it was worth the visual aid.

Did you know Ruby optimizes your code before executing it? If so, ever wonder how that works? The Ruby VM performs various optimizations on bytecode before executing them, one of them called peephole optimizations.

Peephole optimizations come in various forms that are simple yet extremely impactful in making bytecode more elegant, concise, and performant! Let’s learn about how some peephole optimizations work and how these small changes impact the execution of Ruby’s bytecode.