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
Building a toolkit to detect performance regres...
Search
Kir Shatrov
April 22, 2015
Programming
6.3k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Building a toolkit to detect performance regressions in Ruby on Rails core
My talk from RailsConf 2015.
Kir Shatrov
April 22, 2015
More Decks by Kir Shatrov
See All by Kir Shatrov
Running Jobs at Scale
kirs
1
240
Operating Rails in Kubernetes
kirs
3
510
RailsClub 2016
kirs
2
340
Performance regressions in Ruby on Rails Core
kirs
0
240
Развертывание веб-приложений и фреймворк Capistrano
kirs
1
310
Capistrano 3
kirs
4
3.1k
Other Decks in Programming
See All in Programming
Kotlinの15年とServer-Side Kotlin
n_takehata
1
160
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
1
170
npm との違いを手がかりにGo の依存管理を理解したい
optim
0
1k
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.7k
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
180
最近”作らせてる” ローカルAIアプリの話
akit37
0
490
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
290
IBM Bob でAI駆動開発『QC-Playbook』
ichirokano2
0
120
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
820
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
200
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.9k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
530
Abbi's Birthday
coloredviolet
4
10k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Git: the NoSQL Database
bkeepers
PRO
433
67k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.2k
Claude Code のすすめ
schroneko
67
230k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
59k
A Modern Web Designer's Workflow
chriscoyier
699
190k
Darren the Foodie - Storyboard
khoart
PRO
4
4k
Designing for Timeless Needs
cassininazir
1
530
Technical Leadership for Architectural Decision Making
baasie
3
610
Transcript
Kir Shatrov, RailsConf 2015 Building a toolkit to detect performance
regressions in Ruby on Rails core
@kirs @kirshatrov !"
None
Catching Performance Regressions in Rails
What’s a performance regression?
What’s a performance regression in Rails?
Page load 250ms → 4s
Case Study
4.2rc1
None
2 times slower
4.2rc3
Faster framework = Faster app
Examples from Rails commits
Metrics
Timing & Allocations
Faster Methods = Faster App
start = Time.now.to_f sleep 5 ends = Time.now puts "it
took #{ends - start}"
Allocations = GC work Less allocations = less GC work
before = GC.stat[:total_allocated_object] 10_000.times do { "key" => "value" }
end after = GC.stat[:total_allocated_object] puts "allocated: #{after - before}"
Basic primitives
Examples from Rails commits String
None
None
None
None
None
None
None
None
None
None
Examples from Rails commits Hash
None
None
None
None
None
None
Optimize only “hot” code
Track the changes
The Idea to build a service
Track it with benchmarks
Any existing benchmarks?
None
Setup Discourse Populate records Start Unicorn with RAILS_ENV=production Make requests
with Apache Bench to the list of endpoints Print timings and memory usage
Components to benchmark activerecord activemodel actionview actioncontroller activesupport
3.2 – 4.0 – 4.1 – 4.2
None
None
None
None
ActiveRecord Finders require_relative 'support/activerecord_base.rb' require_relative 'support/benchmark_rails.rb' User.create!(name: 'kir', email: '
[email protected]
')
m = Benchmark.rails(100, "activerecord/#{db_adapter}/finders") do User.find(1) end puts m.to_json
Disable GC is necessary Warm up the code Make N
iterations Calculate the mean timing and object allocations
ActiveRecord::Base#create require_relative 'support/activerecord_base.rb' require_relative 'support/benchmark_rails.rb' fields = { name: "Kir",
notes: "Note", created_at: Date.today } Benchmark.rails(1000, "activerecord/#{db_adapter}/create") do Exhibit.create(fields) end
Correct benchmarks
Full app benchmark
Full app benchmark before
stackprof by Aman Gupta github.com/tmm1/stackprof
4.2 4.1
config/environments/production.rb
Full app benchmark after
✅ Benchmarks
None
None
The Service
What do we want? See benchmark for every commit See
benchmark for every PR Report to PR author (“activerecord became 2% slower”) See charts
railsperf.evilmartians.io The prototype of the service. Built in January
rubybench.org by Sam Saffron and Guo Xiang Tan “Alan”
None
3.6GHz Intel® Xeon® E3-1270 v3 Quad-Core 4 x 8GB Micron
ECC Samsung SSD 845DC EVO - 240 GB Sponsored hardware
ruby-bench + rails
github.com/ruby/ruby webhook web app docker server benchmark suite
None
github.com/ruby-bench web app docker files benchmark suite
github.com/ruby-bench web app docker files benchmark suite
github.com/ruby-bench web app docker files benchmark suite
github.com/ruby-bench web app docker files benchmark suite
Results
Running builds for Rails
250k builds for Ruby
MRI performance regression caught
What’s next?
What’s next Pull Request benchmarks Weekly reports JRuby support
Overview What is a performance regression How to track them
How to solve them How to write benchmarks Automate tracking!
How to track your app performance? Study how do Ruby
objects work and how to treat them Write a Discourse-like benchmark and run it on Travis Subscribe to Rails Weekly
Ruby Under a Microscope
http://bit.ly/writing-fast-ruby
How to track your app performance? Study how do Ruby
objects work and how to treat them Write a Discourse-like benchmark and run it on Travis Subscribe to Rails Weekly
Setup the app Populate records Start Unicorn with RAILS_ENV=production Make
requests with Apache Bench to the list of endpoints Print timings and memory usage
How to track your app performance? Study how do Ruby
objects work and how to treat them Write a Discourse-like benchmark and run it on Travis Subscribe to Rails Weekly
bit.ly/railsperf-gh github.com/rubybench bit.ly/railsperf-static
Thanks! @kirs @kirshatrov @evilmartians evilmartians.com