~/talk

Looking Into Peephole Optimizations

Talkat Euruko 2022 · 2022-10-13..10-14· [ruby, compilers-and-language-design]
name:Maple Ong
speakerdeck:wildmaples
slides:none on file

Shows how Ruby applies peephole rewrites inside compile.c using RubyVM::InstructionSequence and the ISeq_peep_optimize pass, finding about 20–30 hardcoded patterns. Demonstrates concrete gains: combining range creation is 5.4× faster, removing a needless splat is 1.31×, replacing array dup with putobject is 1.26×, plus smaller instruction counts and reduced memory. Includes microbenchmarks with whyjitbench and links to YARV docs and the PR that swapped duparray for putobject.

AI-written summary · about

  1. 0:00Start
  2. 13:57Removing unnecessary instructions
  3. 16:30Removing redundant instructions
  4. 23:39Ruby is a dynamic language, so it's hard to get information at compile time.
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.