Project

optimize

0.0
No release in over 3 years
Optimize is an ahead-of-time YARV bytecode optimizer for CRuby. It decodes iseq binaries into an in-memory IR, runs a configurable pipeline of passes (constant folding, inlining, dead-stash elimination, arithmetic reassociation, and others) under a narrow contract that the program's hot path respects, and re-emits an optimized iseq. Intended as a demo and an experiment, not a production compiler.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 1.2
 Project Readme

optimize-rb

The optimize gem — a hand-rolled YARV bytecode optimizer for CRuby — plus the companion post and research for the RubyKaigi 2026 talk Ruby the Hard Way: Writing Bytecode to Optimize Plain Ruby by Samuel Giddins.

Talk page: https://rubykaigi.org/2026/presentations/segiddins.html

Layout

  • optimizer/ — the optimize gem: IR, codec, passes, harness, demos
  • post.md — long-form companion to the talk
  • talk/ — bibliography and references
  • research/ — notes and prior art
  • experiments/ — runnable Ruby experiments (shared Gemfile, numbered subdirs)
  • mcp-server/ — local MCP server that runs Ruby in Docker for the harness
  • docs/superpowers/ — design specs and implementation plans

Prerequisites

  • Ruby 4.0.2 (see each subproject's .ruby-version)
  • Docker Desktop or compatible daemon (for the MCP server)
  • jj for version control

Getting started

cd optimizer && bundle install && bundle exec rake test
cd ../experiments && bundle install
cd ../mcp-server && bundle install && bundle exec rake test

The MCP server is registered via .mcp.json at the repo root; Claude Code picks it up automatically when started from this directory.