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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
35
特殊変数大全
dak2
0
440
登壇その後 - 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
42
Other Decks in Technology
See All in Technology
AIカンパニーへの転換を支えた、エンジニアの仕事の再定義
kworkdev
PRO
2
1k
"優秀な誰か"の下位互換にならないために
yut0naga1_fa
1
1.8k
サブエージェントと Claude Mods で作る独自 Advisor ツールの話
kenichiodo
2
150
go-sqletch
moznion
0
140
OptunaHub: ブラックボックス最適化のためのプラットフォーム
pfn
PRO
0
130
実体験から学ぶ分析エージェントの開発と運⽤
recruitengineers
PRO
8
2.3k
脆弱性診断って、何をしているの? 〜弱点を見つけて、会社の改善につなげるまで〜
keeg
0
910
LocalStack を使ったサーバーレスアプリケーション開発 / Serverless Development with LocalStack
kakakakakku
1
450
10年後、Engineering 行為を剥奪されるとして、わたしたちは、どう、何を創ればいいだろうか。 / If Engineering Is Taken Away in 10 Years, How and What Should We Create?
bitkey
PRO
1
180
AI駆動開発の時代になったのでトヨタ生産方式から見直す
terurou
7
6k
WasmをRustにする
sansantech
PRO
0
250
Webの常識が通じないHTMLメールのダークモード
teamlab
PRO
0
110
Featured
See All Featured
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.2k
Marketing to machines
jonoalderson
1
5.9k
WCS-LA-2024
lcolladotor
0
890
Designing Powerful Visuals for Engaging Learning
tmiket
1
600
Joys of Absence: A Defence of Solitary Play
codingconduct
1
550
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
470
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
400
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
360
Context Engineering - Making Every Token Count
addyosmani
9
1.2k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
sira's awesome portfolio website redesign presentation
elsirapls
0
450
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_