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
800
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
57
Good Enough Types: Heuristic Type Inference for Ruby
riseshia
1
5.1k
型を書かないRuby開発への挑戦
riseshia
0
6.4k
ひとつの開発環境
riseshia
0
220
Conquering Massive Traffic Spikes in Ruby Applications with Pitchfork
riseshia
0
460
スパイクアクセス対策としての pitchfork 導入
riseshia
0
1.1k
NewEngineering 2024 - 繋がっていくサービスを支える開発環境作り
riseshia
0
2k
Hotspot on Coverage
riseshia
0
330
差分ベースで効率的にテストを実行してみる
riseshia
1
880
Other Decks in Technology
See All in Technology
サーバーラックは作る時代! 3Dプリンターで作る10インチラックのススメ
jacopen
2
530
Zero Data Loss Autonomous Recovery Service サービス概要
oracle4engineer
PRO
5
18k
リリースしたで終わらない。 観測できるフロントエンド開発
yamakenji24
4
1.7k
デザインシステムのフィードバックループをほぼ自動化した話
tongari07
1
1.2k
Go でトランザクション、どう書いてますか?
knwoop
2
650
認知の質も文化醸成も。数年取り組んで見えてきた技術広報のKPI設計 / Tech PR KPIs: Lessons on Awareness Quality and Culture After Several Years
bitkey
PRO
0
270
設計手法を「道具」として使いこなすために
a_suenami
7
1.8k
20261119_AgentCore
takuyay0ne
2
340
想定外の利用がプロダクトの価値を広げる
lycorptech_jp
PRO
0
130
技術同人誌を作る方法
yoshimura_datam
0
110
[DBRE Summit 26] DBRE はデータベース運用をどう変えたのか
_awache
0
140
技術書典で本を売る流れ
yoshimura_datam
0
200
Featured
See All Featured
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
670
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.5k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Automating Front-end Workflow
addyosmani
1370
210k
Crafting Experiences
bethany
1
460
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.9k
Large-scale JavaScript Application Architecture
addyosmani
516
110k
Making the Leap to Tech Lead
cromwellryan
135
10k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.6k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
390
Designing Experiences People Love
moore
143
24k