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
introduce Ruby JIT -- the force awakens
Search
Jason Hou
March 24, 2018
Programming
70
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
introduce Ruby JIT -- the force awakens
Shanghai RubyTuesday
Jason Hou
March 24, 2018
More Decks by Jason Hou
See All by Jason Hou
how ruby uses memory and tuning
falm
0
88
Other Decks in Programming
See All in Programming
Spec-Driven Development with AI-Agents: From High-Level Requirements to Working Software
antonarhipov
2
470
Swiftのレキシカルスコープ管理
kntkymt
0
210
TypeSpec で繋ぐ複数プロダクトの型安全
maroon8021
1
420
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
770
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
200
AIエージェントと協働するCLI開発 — BunとOpenClawで学んだこと
yoshikouki
1
240
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
12k
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
170
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
110
AutonomyとControlのあいだ:Graflowで記述するAIエージェント協調
myui
0
110
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
580
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
140
Featured
See All Featured
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
320
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
840
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
580
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
200
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
300
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
720
KATA
mclloyd
PRO
35
15k
GitHub's CSS Performance
jonrohan
1033
470k
The SEO Collaboration Effect
kristinabergwall1
1
480
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
570
Transcript
Ruby JiT THE force awakens 侯俊杰@falm - 薄荷 2018.3.20
CRuby / MRI
克隆人的进攻 • JRuby • TruffleRuby • Crystal • Elixir
Ruby 3 • Typing • Concurrency • Performance Soft-typing Guilds
JIT
JIT 即时编译
PyPy 2 Python 3
MRI
Ruby JIT的历程 yarv2llvm RuJIT OMR JIT LLRB 2015 2011 2017
active
None
RTL-MJIT 新希望
RTL-MJIT • 作者:Vladimir Makarov • RTL: Register Transfer Language⽤用寄存器器VM, 代替YARV的栈VM
• MJIT : Method JIT compiler,MRI JIT
栈 VS 寄存器
YARV puts 2+2 指令 求值栈
寄存器式 trace putself opt_plus r0, 2, 2 opt_send_simple <puts> leave
指令 寄存器器 r0 r1 4 puts 2+2 PC
栈式 VS 寄存器器式 对⽐比 指令条数 栈式 > 寄存器器式 代码尺⼨寸 栈式
< 寄存器器式 移植性 栈式优于寄存器器式 指令优化 栈式更更不不易易优化 解释器器执⾏行行速度 栈式解释器器速度稍慢 代码⽣生成难度 栈式简单 简易易实现中的数据移动次数 栈式移动次数多
MJIT MRI VM Thread worker thread MJIT JIT worker worker
thread worker thread 预编译头 C 代码 动态链接库 header building execution
Optcarrot fps FPS 0 22.5 45 67.5 90 v2.0 base(v2.5)
rtl mjit mjit-cl 85.43 82.06 35.75 39.71 29.02 Intel 3.9GHz i3-7100 with 32GB memory under x86-64 Fedora Core25 1.0x 1.37x 1.23x 2.83x 2.94x
• 优点:速度快,是目前优化速度最快的JIT,并且 内存消耗控制的也比较好 • 缺点:结构复杂,需要整体替换Ruby VM,改动 非常多,目前还无法跑通回归测试。
None
None
YARV-MJIT 原力觉醒
YARV-MJIT • 作者 Takashi Kokubun • 基于RTL-MJIT的基础上去掉RTL的使用原生YARV • 同样Method-based JIT
• VM-generated JIT 编译器
None
Optcarrot fps FPS 0 15 30 45 60 v2.0 v2.6
v2.6 jit off v2.6 jit on 58.88 51.31 51.46 37.32 1.00x 1.38x 1.37x 1.58x Intel 4.0GHz i7-4790K with 16GB memory under x86-64 Ubuntu 8 Cores
• 优点:简单,已经跑通所有测试 • 缺点:并非ruby3x3最终方案,性能提升不显著。
Ruby 2.6 JIT 编译器:YARV-JIT 基础设施:MJIT
总结 • Ruby在JIT上做了了很多尝试。 • MJIT 目前是性能最好的方案,获得Matz的认可。 • Ruby2.6JIT虽不是最终方案,但向前迈出了重要 一步。 •
Ruby 社区仍在为性能做出努力。
Ruby 3x3 绝地反击
THANKS
https://ruby-china.org/topics/35131