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
KaigiEffect.new(name: "dak2").generate
Search
dak2
April 24, 2026
Technology
140
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
KaigiEffect.new(name: "dak2").generate
Lightning Talks on Hakodate Tram at Rub
2026-04-25
RubyKaigi 2026
dak2
April 24, 2026
More Decks by dak2
See All by dak2
特殊変数大全
dak2
0
370
登壇その後 - ZJIT への興味とハック
dak2
0
27
現場のトークンマネジメント
dak2
1
330
No Types Needed, Just Callable Method Check
dak2
1
9.1k
MCP Security Best Practices に見るセキュリティリスクとmodelcontextprotocol/ruby-sdk の authorization の現在地
dak2
0
76
自然言語で ActiveRecord を操作する試み
dak2
0
67
DoD x RBS
dak2
0
41
Other Decks in Technology
See All in Technology
しろおびから始める!ログ活用の第一歩
shumei_ito
0
890
転んだ話が背中を預ける理由になる / A_story_about_falling_down_gives_you_a_reason_to_watch_each_other_s_backs.pdf
pauli
3
350
Essential architectural thinking (revised edition)
ufried
0
110
ファミコンでPHPを動かす / PHP on the Famicom side b
tomzoh
0
140
UniFi(ユニファイ)AIカメラの現場活用
ludicmind
1
410
"優秀な誰か"の下位互換にならないために
yut0naga1_fa
1
1.7k
今さら理解するウェブフォントver.2026
takanorip
3
670
全PRの83%が AIレビューだけでマージできるようになった開発組織は その後どうなったか @2026/10
athug
0
140
Kiro Crewをはじめよう
kizawa2020
1
140
V8のArray.prototype.flatを最大約20倍速くするまでと、巨大OSSへの大規模コミットの道のり
riyaamemiya
0
250
More Freedom on the Same Shared GPU Cluster: A Small Team’s Experience with vCluster
nttcom
0
150
AIがコードを書く時代に、エンジニアは何で自分の価値を証明するのか / In an era where AI writes code how do engineers prove their value
carta_engineering
2
830
Featured
See All Featured
Statistics for Hackers
jakevdp
799
230k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
58k
Paper Plane (Part 1)
katiecoart
PRO
2
11k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
540
Exploring anti-patterns in Rails
aemeredith
4
530
Side Projects
sachag
456
43k
The Curious Case for Waylosing
cassininazir
1
560
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
940
Building the Perfect Custom Keyboard
takai
2
900
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
530
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
Transcript
KaigiEffect.new(name: "dak2").generate Daichi Kamiyama @_dak2_ Lightning Talks on Hakodate Tram
at RubyKaigi 2026 2026-04-25
Ruby を AOT コンパイル どれくらい速い? spinel で、 公式 Ruby gem
をコンパイルする実験
// test subject ipaddr Ruby 同梱の default gem
// workload 1M 個の IP を CIDR 包含判定 10.0.0.0/8 に入るか?
— 文字列 parse · object 生成 · bit 演算の総合テスト
// benchmark script ipaddr_bench.rb (抜粋) cidr = ipaddr_from_str("10.0.0.0/8") n =
1_000_000 count = 0 i = 0 while i < n addr_int = (i * 2654435761) & 0xffffffff # Knuth hash a = (addr_int >> 24) & 0xff b = (addr_int >> 16) & 0xff c = (addr_int >> 8) & 0xff d = addr_int & 0xff str = a.to_s + "." + b.to_s + "." + c.to_s + "." + d.to_s ip = ipaddr_from_str(str) count = count + 1 if cidr.include?(ip) i = i + 1 end puts "matched: #{count} / #{n}"
2.9x CRuby 3.15s → spinel 1.08s
// 最初に書いた initialize ipaddr_bench.rb class IPAddr def initialize(str) slash =
find_slash(str) # local prefix = str[0, slash] # local prefixlen = str[slash + 1, str.length].to_i # local masklen = 32 - prefixlen # local @addr = parse_ipv4(prefix) # ivar @mask = (0xffffffff >> masklen) << masklen # ivar end end ごく普通の Ruby。 でも、 これが spinel では C コンパイルで死ぬ。
// spinel's convention initialize は 単純代入だけ @foo = foo 以外は書かない
// spinel の内部挙動 initialize から 2 本の C 関数 が生成される
C には overload も継承も無い — 呼ばれ方ごとに別関数にするしかない sp_IPAddr_new ← IPAddr.new("...") · factory (alloc + 初期化) sp_IPAddr_initialize ← class Sub < IPAddr; def initialize ... super(...) · callable spinel_codegen.rb:9677 のコメント: “Initialize function (for super calls)”
// 問題はここ _initialize のループには else 節が無い spinel_codegen.rb:9719 stmts.each { |sid|
if @nd_type[sid] == "InstanceVariableWriteNode" emit_raw(" self->#{ivar} = #{val};") end # ← else 節が無い } ローカル変数代入 · if/else · メソッド呼び出し — 全部 黙って捨てられる
// だから、こうなる Ruby の initialize def initialize(str) slash = find_slash(str)
# 捨てられる prefix = str[0, slash] # 捨てられる prefixlen = str[slash+1, str.length].to_i # 捨てられる masklen = 32 - prefixlen # 捨てられる @addr = parse_ipv4(prefix) # ✓ emit @mask = (0xffffffff >> masklen) << masklen # ✓ emit end 生成された sp_IPAddr_initialize static inline void sp_IPAddr_initialize(sp_IPAddr *self, ...) { self->addr = parse_ipv4(lv_prefix); self->mask = ((4294967295 >> lv_masklen) << lv_masklen); } error: use of undeclared identifier 'lv_prefix' error: use of undeclared identifier 'lv_masklen'
// before → after × 失敗 — parse を初期化内で def
initialize(str) slash = find_slash(str) prefix = str[0, slash] masklen = 32 - prefixlen @addr = parse_ipv4(prefix) @mask = (0xffffffff >> masklen) << masklen end ✓ 成功 — parse は外に出す def initialize(addr, mask) @addr = addr @mask = mask end def ipaddr_from_str(str) # parse して .new(...) に渡す IPAddr.new(addr, mask) end
None
あなた の KaigiEffect は? Thank you · @_dak2_