Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
RubyKaigi Dev Meeting 2025
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Aaron Patterson
April 15, 2025
Programming
6.6k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
RubyKaigi Dev Meeting 2025
Aaron Patterson
April 15, 2025
Transcript
23 slides
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 😅
More Decks by Aaron Patterson
See All by Aaron Patterson
Faster FFI for Ruby
tenderlove
0
120
RubyKaigi 2025: Class New, A New Approach
tenderlove
0
320
Speeding up Instance Variables in Ruby 3.3
tenderlove
2
620
[Feature #20425] Speeding up delegate methods
tenderlove
3
410
RailsConf 2023
tenderlove
30
1.6k
Don't @ Me! Faster Instance Variables with Object Shapes
tenderlove
1
600
RailsConf 2022 Keynote
tenderlove
2
730
Some Assembly Required
tenderlove
1
680
HexDevs 2021
tenderlove
1
610
Other Decks in Programming
See All in Programming
AI-Powered Domain-Driven Design
ziobrando
0
470
コード生成時代のAPI定義を支えるRequest Spec移行
pvcresin
0
280
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
210
Scalaの型でマルチテナントの認可を守る
nextbeatdev
0
160
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
360
GraphQL の onError と Nullability のこれから
quramy
0
220
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
1
370
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
170
高橋メソッドでCVE解説シリーズ 〜CVE-2026-112816〜
hakkadaikon
0
270
Kotlin JVM用に作られたライブラリのKMPを前提とした再設計
jsoizo
0
200
AIが実装を担う時代の「技術設計」と「チームマネジメント」
kamina_zzz
2
280
[DroidKnights 2026] Workflow AX 적용기 — 자동 정책 정리부터 E2E까지
dayeon
0
110
Featured
See All Featured
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
530
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
670
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.4k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
350
Ethics towards AI in product and experience design
skipperchong
2
470
Joys of Absence: A Defence of Solitary Play
codingconduct
1
580
Highjacked: Video Game Concept Design
rkendrick25
PRO
2
580
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Faster Mobile Websites
deanohume
310
32k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
630
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
3k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
490