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
KaigiEffect.new(name: "dak2").generate
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
dak2
April 24, 2026
Technology
79
1
Share
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
No Types Needed, Just Callable Method Check
dak2
1
3.2k
MCP Security Best Practices に見るセキュリティリスクとmodelcontextprotocol/ruby-sdk の authorization の現在地
dak2
0
40
自然言語で ActiveRecord を操作する試み
dak2
0
49
DoD x RBS
dak2
0
13
Other Decks in Technology
See All in Technology
AIが盛んな時代に 技術記事を書き始めて起きた私の中での小さな変化
peintangos
0
360
知ってた?JavaScriptの"正しさ"を検証するテストが5万以上もあること(Test262)
riyaamemiya
1
160
Building Production-Ready Agents Microsoft Agent Framework
_mertmetin
0
160
Sociotechnical Architecture Reviews: Understanding Teams, not just Artefacts
ewolff
1
150
『生成AI時代のクレデンシャルとパーミッション設計 — Claude Code を起点に』の執筆企画
takuros
3
2.3k
AI時代に、 データアナリストがデータエンジニアに異動して
jackojacko_
0
250
ハーネスエンジニアリング入門
hatyibei
0
110
「誰一人取り残されない」 AIエージェント時代のプロダクト設計思想 Product Management Summit 2026
mizushimac
1
3k
Oracle Cloud Infrastructure:2026年4月度サービス・アップデート
oracle4engineer
PRO
0
370
オライリーイベント登壇資料「鉄リサイクル・産廃業界におけるAI技術実応用のカタチ」
takarasawa_
0
330
AIエージェントの支払い基盤 AgentCore Payments概要
kmiya84377
1
140
「強制アップデート」か「チームの自律」か?エンタープライズが辿り着いたプラットフォームのハイブリッド運用/cloudnative-kaigi-hybrid-platform-operations
mhrtech
0
140
Featured
See All Featured
Music & Morning Musume
bryan
47
7.2k
The browser strikes back
jonoalderson
0
1k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
110
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.4k
Discover your Explorer Soul
emna__ayadi
2
1.1k
How to Think Like a Performance Engineer
csswizardry
28
2.6k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
500
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
550
Everyday Curiosity
cassininazir
0
200
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
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_