Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
YJIT: Dive into Ruby's JIT compiler written in ...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Takashi Kokubun
September 23, 2022
Programming
2.3k
2
Share
YJIT: Dive into Ruby's JIT compiler written in Rust / Rust.Tokyo 2022
Rust.Tokyo 2022
Takashi Kokubun
September 23, 2022
More Decks by Takashi Kokubun
See All by Takashi Kokubun
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
3.3k
一度始めたらやめられない開発効率向上術 / Findy あなたのdotfilesを教えて!
k0kubun
4
3.1k
ZJIT: The Ruby 4 JIT Compiler / Ruby Release 30th Anniversary Party
k0kubun
1
510
ZJIT: The Future of Ruby Performance / San Francisco Ruby Conference 2025
k0kubun
1
120
ZJIT: Building a New JIT Compiler for Ruby / REBASE 2025
k0kubun
0
120
Deoptimization: How YJIT Speeds Up Ruby by Slowing Down / RubyKaigi 2025
k0kubun
2
4.2k
YJIT Makes Rails 1.7x faster / RubyKaigi 2024
k0kubun
7
16k
Ruby JIT Hacking Guide / RubyKaigi 2023
k0kubun
2
11k
Towards Ruby 4 JIT / RubyKaigi 2022
k0kubun
3
12k
Other Decks in Programming
See All in Programming
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
180
開発とはなにか、Essenceカーネルで見えるもの
ukin0k0
0
210
プラグインで拡張される Context をtype-safe にする難しさと設計判断
kazupon
2
290
ふつうのFeature Flag実践入門
irof
0
110
TSKaigi 2026 TypeScriptバックエンドのオブザーバビリティ戦略 — Datadog × NestJSの実践
taiseiyamamotoan
1
180
1人1案件のプロダクトエンジニア時代に、"プロセス監督"としてチャレンジしたこと
non0113
0
300
AIエージェントと協働するCLI開発 — BunとOpenClawで学んだこと
yoshikouki
1
210
Modding RubyKaigi for Myself
yui_knk
0
430
ローカルLLMでどこまでコードが書けるか / How much code can be written on a local LLM
kishida
2
410
Sans tests, vos agents ne sont pas fiables
nabondance
0
160
Migrations : C'est une question d'hygiène !
vinceamstoutz
0
1.8k
Copilot CLI の継戦能力を高める コンテキスト管理
nozomutu
1
940
Featured
See All Featured
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.2k
Mind Mapping
helmedeiros
PRO
1
200
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
170
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
810
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
200
Faster Mobile Websites
deanohume
310
31k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
360
Site-Speed That Sticks
csswizardry
13
1.2k
Transcript
YJIT: Dive into Ruby's JIT compiler written in Rust @k0kubun
/ Rust.Tokyo 2022
Me • @k0kubun • Shopify ◦ YJIT team • Ruby
committer ◦ MJIT maintainer
What’s YJIT?
None
None
None
None
How does YJIT work?
How YJIT works Ruby code
How YJIT works 1 + 2 Parse Ruby code Abstract
Syntax Tree
How YJIT works 1 + 2 Parse Ruby code Abstract
Syntax Tree putobject 1 putobject 2 opt_plus leave Compile Bytecode
How YJIT works 1 + 2 Parse Ruby code Abstract
Syntax Tree putobject 1 putobject 2 opt_plus leave Compile JIT Bytecode Machine code
How YJIT works putobject 1 putobject 2 opt_plus leave JIT
? Machine code Bytecode
How YJIT works: Ruby 3.1 putobject 1 putobject 2 opt_plus
leave x86_64 Codegen Machine code Bytecode
How YJIT works: Ruby 3.2 putobject 1 putobject 2 opt_plus
leave Machine code Bytecode
How YJIT works: Ruby 3.2 putobject 1 putobject 2 opt_plus
leave Machine code Bytecode
Lazy Basic Block Versioning
Lazily compile basic blocks
getlocal a getlocal b opt_plus setlocal c getlocal c putobject
1 opt_gt branchunless getlocal a leave getlocal b leave Lazily compile basic blocks
Lazily compile basic blocks
getlocal a getlocal b opt_plus setlocal c getlocal c putobject
1 opt_gt branchunless Branch stub Branch stub Lazily compile basic blocks
getlocal a getlocal b opt_plus setlocal c getlocal c putobject
1 opt_gt branchunless getlocal a leave Branch stub Lazily compile basic blocks
getlocal a getlocal b opt_plus setlocal c getlocal c putobject
1 opt_gt branchunless getlocal a leave Branch stub Lazily compile basic blocks
getlocal a getlocal b opt_plus setlocal c getlocal c putobject
1 opt_gt branchunless getlocal a leave getlocal b leave Lazily compile basic blocks
Why lazy compilation? 1. Better code locality a. Only compile
used paths b. Related code is put together
Why lazy compilation? 1. Better code locality a. Only compile
used paths b. Related code is put together 2. More type information
Type Profiling
Type Profiling getlocal a getlocal b opt_plus
Type Profiling getlocal a getlocal b opt_plus
Type Profiling getlocal a getlocal b jmp regenerate
Type Profiling getlocal a getlocal b jmp regenerate
Type Profiling getlocal a getlocal b jmp regenerate a: 1
b: 2
Type Profiling getlocal a getlocal b opt_plus (int) setlocal c
getlocal c putobject 1 opt_gt branchunless
Passes • CodeGen -> Split -> Alloc Regs
Passes • CodeGen -> Split -> Alloc Regs
IR
IR Split
IR Split Alloc Regs
Rust Challenges
Clang and Bindgen Clang dependency or Per-architecture codegen?
Mutable Borrow
Next steps • Code GC • Register allocation • Method
inlining
Conclusion • We reviewed the architecture of YJIT • Rust
has been useful for transforming IR