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
RubyKaigi Dev Meeting 2025
Search
Aaron Patterson
April 15, 2025
Programming
5.7k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
RubyKaigi Dev Meeting 2025
Aaron Patterson
April 15, 2025
More Decks by Aaron Patterson
See All by Aaron Patterson
Faster FFI for Ruby
tenderlove
0
62
RubyKaigi 2025: Class New, A New Approach
tenderlove
0
270
Speeding up Instance Variables in Ruby 3.3
tenderlove
2
580
[Feature #20425] Speeding up delegate methods
tenderlove
3
370
RailsConf 2023
tenderlove
30
1.5k
Don't @ Me! Faster Instance Variables with Object Shapes
tenderlove
1
560
RailsConf 2022 Keynote
tenderlove
2
690
Some Assembly Required
tenderlove
1
650
HexDevs 2021
tenderlove
1
580
Other Decks in Programming
See All in Programming
AIが無かった頃の素敵な出会いの話
codmoninc
1
380
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
230
今さら聞けない .NET CLI
htkym
0
180
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
1.7k
ビデオ通話が繋がる0.2秒で何が起きているのか
supurazako
2
170
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
210
なぜ関数型プログラミングで「型」と「証明」が語られるのか #fp_matsuri
kajitack
3
1.1k
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
290
torikago - Ruby::Boxで照らすモジュラモノリスの実行境界
se4weed
1
330
React本体のコードリーディング
high_g_engineer
1
130
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
650
メールのエイリアス機能を履き違えない
isshinfunada
0
220
Featured
See All Featured
For a Future-Friendly Web
brad_frost
183
10k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
440
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
330
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
260
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
119
120k
So, you think you're a good person
axbom
PRO
2
2.1k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
Transcript
Inline Class#new Feature #21254
Implement Class#new in Ruby class Class def new(...) Primitive.attr! :c_trace
Primitive.pop!( Primitive.send_delegate!( Primitive.dup!(Primitive.rb_class_alloc2), :initialize, ...)) end end class BasicObject def initialize Primitive.attr! :c_trace nil end end
Class#new ➡ Ruby
Inline Class#new Feature #21254
Instructions
Before > ruby --dump=insns -e'Object.new' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,10)> 0000
opt_getconstant_path <ic:0 Object> ( 1)[Li] 0002 opt_send_without_block <calldata!mid:new, argc:0, ARGS_SIMPLE> 0004 leave
After > ./miniruby --dump=insns -e'Object.new' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,10)> 0000
opt_getconstant_path <ic:0 Object> ( 1)[Li] 0002 putnil 0003 swap 0004 opt_new <calldata!mid:new, argc:0, ARGS_SIMPLE>, 11 0007 opt_send_without_block <calldata!mid:initialize, argc:0, FCALL|ARGS_SIMPLE> 0009 jump 14 0011 opt_send_without_block <calldata!mid:new, argc:0, ARGS_SIMPLE> 0013 swap 0014 pop 0015 leave
Speedup
Positional Parameters Allocations per Second by Ruby version Allocations Per
Second 0 9500000 19000000 28500000 38000000 Number of Parameters 0 1 2 3 4 5 6 7 8 9 10 Ruby 3.5 + inlining Ruby 3.4
~1.8x Faster
Keyword Parameters Allocations per second by Ruby version Allocations Per
Second 0 10000000 20000000 30000000 40000000 Number of Parameters 0 1 2 3 4 5 6 7 8 9 10 Ruby 3.5+inlining Ruby 3.4
3 Keyword Params: 3.2x faster
10 Keyword Params: 6.2x faster
Positional Parameters + Varied Classes Allocations per second by Ruby
version (varying allocated class) Allocations per Second 0 9500000 19000000 28500000 38000000 Number of Parameters 0 1 2 3 4 5 6 7 8 9 10 Ruby 3.5+Inlining Ruby 3.4
Keyword Parameters + Varied Classes Allocations per second by Ruby
version (varying allocated class) Allocations Per Second 0 10000000 20000000 30000000 40000000 Number of Parameters 0 1 2 3 4 5 6 7 8 9 10 Ruby 3.5+Inlining Ruby 3.4
Downsides
More memory
Measure ISeq size How many bytes does the “alloc” method
use? require "objspace" def alloc Object.new end m = method(:alloc) insn = RubyVM::InstructionSequence.of(insn) puts ObjectSpace.memsize_of(insn) Ruby 3.5 + inlining: 656 bytes Ruby 3.4: 544 bytes +122 Bytes
Real World Memory Increase (ISeq Only) 0.5% Increase in ISeq
Size (Ruby 3.4.2 vs 3.5.0+inline) irb(main):001> 737191972 - 733354388 => 3837584 Shopify M onolith ISeq Sizes
Real World Memory Increase (all memory) 1mb increase total (~4GB
heap) irb(main):001> 3981075617 - 3979926505 => 1149112 Shopify M onolith Total H eap
Different Stack Trace
Stack Trace is Different Class#new is missing class Foo def
initialize puts caller end end def hello Foo.new end hello > ruby test.rb test.rb:8:in 'Class#new' test.rb:8:in 'Object#hello' test.rb:11:in '<main>' Ruby 3.4 > ./ruby test.rb test.rb:8:in 'Object#hello' test.rb:11:in '<main>' Ruby 3.5 + inlining
No Test Failures 😅