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
Class.new is all you need
Search
Shia
April 22, 2026
Technology
780
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Class.new is all you need
RubyKaigi 2026 LT
Shia
April 22, 2026
Transcript
28 slides
RubyKaigi 2026 LT Shia@STORES Class.new is all you need
SIM SANGYONG (@shia) - STORES Inc. - GitHub: @riseshia -
X: @riseshia Self Introduction 2
SIM SANGYONG (@shia) - STORES Inc. - GitHub: @riseshia -
X: @riseshia - And…Day 3!!! Self Introduction 3
"type-guessr" needed to collect info from project code at startup
and it was slow. So, I profiled and… Background 4
ko1: "Class.new is faster than them" shia: "…!?!?" Background 5
Target: Initialization speed - Data.define, Struct, Class - kwargs, positional
args - 1 ivar, 8 ivars Ruby 4.0.1 / linux / no YJIT So, benchmark it 6
Result 7 1 field 8 fields
- Class.new > Struct.new >> Data.define.new - kwargs are slow
- more ivars, more slower Observation 8
Observation 9 8 fields - Class.new > Struct.new >> Data.define.new
- kwargs are slow - more ivars, more slower Note: Class.new outperforms with YJIT
See perf results 10 "perf record -g --call-graph dwarf" Ruby
4.0.1 / linux / no YJIT / ivar 1 field
See perf results 11
See perf results 12
See perf results 13
See perf results 14
See perf results 15
- Is kwargs initialization optimized? - Create Hash for kwargs
on initialization or not - Is ivar access optimized? - Byte code caching with object shape applied or not - Does the object need to be frozen? Why?? 16
shia: "I found it really is.." ko1: "We optimize what
people use most, so yeah" shia: "That's absolutely true😂" After talk 17
I originally used Data because I vaguely assumed Data/Struct was
lighter than Class. Reality was different at least object initialization. Did you know that? Summary 18
〜Fin〜 19
🤔 20
If "Class" is the fastest, why not re-implement these with
it?? 🤔🤔🤔 How to speed up Struct or Data.define 21
Re-impl Struct with "Class", and benchmark again: (8 fields, YJIT
off/on) How to speed up Struct or Data.define 22
It’s really fast! Let’s submit this patch!!!
Let’s submit this patch!!! 24
Submit this patch…? 25
🫠 26
🚮 27
28 You can check the full benchmark & RubyStruct implementation!
https://github.com/riseshia/class-new-is-all-you-need Class.new might be all you need (if initialization perf matters)
More Decks by Shia
See All by Shia
猫の手も借りたい
riseshia
0
53
Good Enough Types: Heuristic Type Inference for Ruby
riseshia
1
5k
型を書かないRuby開発への挑戦
riseshia
0
6.4k
ひとつの開発環境
riseshia
0
220
Conquering Massive Traffic Spikes in Ruby Applications with Pitchfork
riseshia
0
450
スパイクアクセス対策としての pitchfork 導入
riseshia
0
1.1k
NewEngineering 2024 - 繋がっていくサービスを支える開発環境作り
riseshia
0
2k
Hotspot on Coverage
riseshia
0
320
差分ベースで効率的にテストを実行してみる
riseshia
1
870
Other Decks in Technology
See All in Technology
これからのデータエンジニアの役割について考える / Rethinking the Role of Data Engineers in the AI Era
okiyuki99
0
430
顧客合意を取りながら進めるAWSコスト削減の実践
optim
0
160
業務でAWSをあまり使っていない私が、AWSへのモチベを保つ方法
smt7174
0
190
AWS Quick 入門 | 目指せ Quick マスター 01
inariku
PRO
2
330
2026 Apache Flink Community Checkpoint
rmetzger
0
240
田んぼから始まる挑戦 〜新米農家の1年目〜
miu_crescent
PRO
0
130
うちなーぐちが認識できるなら、秋田弁もいけるはず!? Amazon Transcribe方言チューニング検証
ryouto715
1
170
MCPでAIが自分で調べに行く
cdataj
0
160
SREのためのFinOps入門
muziyoshiz
3
1.4k
[dbts2026]数十PBの超巨大データ×AI活用を支えるSnowflakeの実力〜大規模環境におけるアーキテクチャと運用のリアル〜
y_matsubara
0
140
Context Ontology Accelerator 入門 (業務データの意味を、AI エージェントに渡す)
inariku
PRO
3
660
田んぼの見回りをIoTで減らしたい!水位監視から電池駆動カメラまでの試行錯誤
itosoft
1
120
Featured
See All Featured
Between Models and Reality
mayunak
4
570
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7.1k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
440
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
60k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
660
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
560
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Practical Orchestrator
shlominoach
192
12k
The untapped power of vector embeddings
frankvandijk
2
2k
Raft: Consensus for Rubyists
vanstee
143
7.9k