~/talk

Looking Into Peephole Optimizations

Talkat RubyConf Mini 2022 · 2022-11-15..11-17· [ruby]
name:Maple Ong
speakerdeck:wildmaples
slides:none on file

Shows that MRI runs a peephole pass after compilation (implemented in compile.c calling iseq_peep_optimize) over YARV bytecode produced by RubyVM::InstructionSequence, with about 20+ cases of pattern replacement. Examples include shrinking range construction to one instruction (measured 5.4× faster), removing redundant splat/dup (1.3× and 1.26× gains, sometimes within noise), and replacing literal-array allocations; benchmarks use yjit_bench and report modest instruction and memory reductions.

AI-written summary · about

  1. 0:00Start
  2. 4:01Peephole optimization is used in other layers of the stack and other languages.
  3. 7:16How does Ruby implement peephole optimization?
  4. 23:12Ruby 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.