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
[RailsConf 2024] From slow to go: Rails profili...
Search
Vladimir Dementyev
May 08, 2024
Programming
3.2k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
[RailsConf 2024] From slow to go: Rails profiling hands-on
https://evilmartians.com/events/from-slow-to-go-rails-test-profiling-hands-on-railsconf-2024
Vladimir Dementyev
May 08, 2024
More Decks by Vladimir Dementyev
See All by Vladimir Dementyev
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
870
[GopherCon 2026] Unlocking Real-World Go Mutex Usage Patterns by Writing a Mutex Linter
palkan
0
170
[BalkanRuby 2026] Drop your app/services!
palkan
3
1.1k
[RubyKaigi 2026] Require Hooks
palkan
1
810
[Tropical on Rails] From 1 to 2
palkan
1
230
[SF Ruby Feb'26] The Silicon Heel
palkan
0
490
[SF Ruby Conf 2025] Rails X
palkan
3
1.5k
[SF Ruby] Presence ain't perfect
palkan
0
1.3k
[WasmCon 2024] From client to server: Ruby on Rails on WebAssembly
palkan
0
2.3k
Other Decks in Programming
See All in Programming
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
160
気持ちぃ〜角丸 Squircle
ryu1013
0
320
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
2
1.1k
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
310
Seven New Principles of Software Engineering
yegor256
0
190
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
200
【加筆修正版】Laravel のアプリケーションをどこにデプロイするか #phpcon_ehime
akase244
0
160
AWSに止められる覚悟してますか?
morizo_1984
2
540
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
170
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
2
890
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
8
2.3k
No More NoSuchMethodError
exoego
1
110
Featured
See All Featured
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.7k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
490
The Cost Of JavaScript in 2023
addyosmani
55
10k
Producing Creativity
orderedlist
PRO
348
41k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.4k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
950
Being A Developer After 40
akosma
92
590k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
370
Believing is Seeing
oripsolob
1
250
Designing for Timeless Needs
cassininazir
1
530
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
950
Transcript
None
From slow to go: Rails test profiling hands-on Vladimir Dementyev
Evil Martians
palkan_tula palkan Why are we here? What's the plan? Who
are you? 3 Warming up Or waiting for everyone's dip rspec to pass
palkan_tula palkan You are here = = your tests are
slow 4
palkan_tula palkan Longer CI builds (also more expensive) Longer local
runs (or "local CI" builds) 5 Slow tests
palkan_tula palkan Longer CI builds (also more expensive) Longer local
runs (or "local CI" builds) Longer feedback loops More distraction, less productivity 6 Slow tests
palkan_tula palkan 🔍 Identify slowness causes and patterns 💊 Treat
them well 🔁 Repeat until satisfied 7 From slow to go
palkan_tula palkan 8
palkan_tula palkan Specialized profiler for Ruby test suites Optimization toolbox
to speed up tests with less refactoring 9 TestProf test-prof.evilmartians.io
palkan_tula palkan Used by GitHub, Discourse, Gitlab, Dev.to, and many
more Used by YOU at this workshop! 10 TestProf test-prof.evilmartians.io
11 github.com/palkan
12 evilmartians.com
13
palkan_tula palkan 14 X
palkan_tula palkan 15 Disclaimer: Mastodon team already did some test
performance work (via TestProf), so I had to revert a few optimizations in the workshop's version of the codebase (so we can have more fun)
palkan_tula palkan General profiling (Stackprof, Vernier, sampling) Focused profiling (TagProf,
EventProf) Factories overhead elimination (let_it_be) 16 The plan
palkan_tula palkan Local time: 8 : 30 ➡ 2 :
30 CI time: 14 : 30 ➡ 8 : 00 17 Results
palkan_tula palkan Rails tests occupy only for a portion of
a CI build time No need to optimize beyond other components 18 CI vs Rails tests
palkan_tula palkan General profiling 19
20
palkan_tula palkan Workshop instructions 21 # rails_helper.rb TestProf::EventProf.monitor( Paperclip::Attachment, 'paperclip.post_process',
:post_process )
palkan_tula palkan Workshop instructions 22 TAG_PROF=type \ TAG_PROF_FORMAT=html \ TAG_PROF_EVENT=sql.active_record,factory.create,
sidekiq.inline,paperclip.post_process \ be rspec
palkan_tula palkan Coverage: opt-out ➡ opt-in gem "debug", require: false
Webpacker: cache_manifest: true 23 Findings
palkan_tula palkan Logging—no effect when disk write is fast (SSD,
Docker volumes on Mac) Thousands of I18n YAMLs—handled by Bootsnap 24 Findings
25
palkan_tula palkan Do not require test-specific profiling skills Takes the
most significant amount of time (sampling helps) Highlights low-hanging fruits 26 General profiling
palkan_tula palkan Focused profiling 27
palkan_tula palkan Similar tests has similar problems Focus on most
time consuming test types, not individual outliers 28 Focused profiling
29
palkan_tula palkan Reduced the number of tests to analyze by
~2x Divided tests into smaller groups (~1min run time) for further analysis 30 Focused profiling
palkan_tula palkan TagProf EventProf RspecStamp (RSTAMP) 31 Tools
palkan_tula palkan Sidekiq: inline! ➡ fake! Paperclip::Testing.fake! 32 Findings
33
palkan_tula palkan Workshop instructions 34 # .rspec-local --tag ~paperclip:process
palkan_tula palkan 35 What's next?
palkan_tula palkan Factories 36
palkan_tula palkan 37 FPROF = 1 \ EVENT_PROF=factory.create \ be
rspec spec/models Workshop instructions
palkan_tula palkan Factory cascades Too many disposable records (no reuse
or recycle) Create vs. build 38 Factories vs. slow tests
39
palkan_tula palkan FactoryProf RSpecDissect before_all / let_it_be 40 Tools
palkan_tula palkan No cascades found Many tests share the same
context Reusing records between examples brings up to 6x speed up! 41 Findings
palkan_tula palkan Replacing let/let! with let_it_be works in ~90% of
tests The rest may require some refactoring (usually minor) 42 Findings
palkan_tula palkan Every file must be treated individually (routine) Extracting
shared contexts may help simplify future optimizations (e.g., adding fixtures) 43 Findings
palkan_tula palkan Homework 44
palkan_tula palkan Discover more TestProf tools (Autopilot, RuboCop cops, Factory
Doctor) Make YOUR tests faster Become a Mastodon contributor! 45 Homework
Thank you Visit TestProf and Evil Martians at the Hack
Day!