Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Performance regressions in Ruby on Rails Core
Search
Kir Shatrov
September 27, 2015
Programming
0
230
Performance regressions in Ruby on Rails Core
Slides for my Railsclub Moscow 2015 talk.
Kir Shatrov
September 27, 2015
Tweet
Share
More Decks by Kir Shatrov
See All by Kir Shatrov
Running Jobs at Scale
kirs
1
220
Operating Rails in Kubernetes
kirs
3
500
RailsClub 2016
kirs
2
320
Building a toolkit to detect performance regressions in Ruby on Rails core
kirs
3
5.9k
Развертывание веб-приложений и фреймворк Capistrano
kirs
1
290
Capistrano 3
kirs
4
2.9k
Other Decks in Programming
See All in Programming
Head of Engineeringが現場で回した生産性向上施策 2025→2026
gessy0129
0
200
15年目のiOSアプリを1から作り直す技術
teakun
0
570
ご飯食べながらエージェントが開発できる。そう、Agentic Engineeringならね。
yokomachi
1
270
Raku Raku Notion 20260128
hareyakayuruyaka
0
430
AI時代でも変わらない技術コミュニティの力~10年続く“ゆるい”つながりが生み出す価値
n_takehata
2
560
AWS Infrastructure as Code の新機能 2025 総まとめ 〜SA 4人による怒涛のデモ祭り〜
konokenj
10
3k
Rubyと楽しいをつくる / Creating joy with Ruby
chobishiba
0
200
Geminiの機能を調べ尽くしてみた
naruyoshimi
0
190
Claude Codeと2つの巻き戻し戦略 / Two Rewind Strategies with Claude Code
fruitriin
0
200
AI時代のソフトウェア開発でも「人が仕様を書く」から始めよう-医療IT現場での実践とこれから
koukimiura
0
120
Beyond the Basics: Signal Forms
manfredsteyer
PRO
0
110
Oxlint JS plugins
kazupon
1
1.2k
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.3k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
71
How to Think Like a Performance Engineer
csswizardry
28
2.5k
Unsuck your backbone
ammeep
671
58k
GitHub's CSS Performance
jonrohan
1032
470k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
130
How to make the Groovebox
asonas
2
2k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.1k
Everyday Curiosity
cassininazir
0
150
Into the Great Unknown - MozCon
thekraken
40
2.3k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.7k
Transcript
RAILSCLUB 2015 Kir Shatrov 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
higher is faster
higher is faster
higher is faster
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 higher is faster
Full app benchmark before higher is faster
stackprof by Aman Gupta github.com/tmm1/stackprof
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 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/rails/rails webhook web app docker server benchmark suite
None
github.com/ruby-bench web app docker files benchmark suite
Results
Running builds for Rails
Performance regressions caught
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
Спасибо! @kirs @kirshatrov @evilmartians evilmartians.com