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
Debugging and Profiling Rails App
Search
David Paluy
January 28, 2013
How-to & DIY
240
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Debugging and Profiling Rails App
Overview of Debugging and Profiling tools for Rails
David Paluy
January 28, 2013
More Decks by David Paluy
See All by David Paluy
LLM Telemetry & Evals as First Class Rails Concerns - BlueRidgeRuby 2026
dpaluy
0
48
Tools to help you better understand the code
dpaluy
0
150
Ruby On Rails coding conventions, standards and best practices
dpaluy
1
1.5k
Faster on Rails
dpaluy
2
240
How to Prepare 3 min Fundraising Presentation
dpaluy
0
1k
Other Decks in How-to & DIY
See All in How-to & DIY
おっきなガジェットの回線事情
2bo
1
230
多摩.dev で草を食べる話をしたら カンファレンスに登壇していた / from-eating-weeds-to-a-conference
aokiplayer
1
290
「無理」を「コントロール」するスキル / Skills to Control "Muri"
hageyahhoo
6
4.4k
JAWS-UG/AWS Communities Updates 2025/11/8 JAWS-UG 島根支部
awsjcpm
1
180
ドローンをAWSで制御してみた
nagi900
0
180
人見知りな HUB おじさんが 会話のハードルを超え、 今度は誰かの踏み台になろうとする話/hub-guy-as-a-stepping-stone
aokiplayer
2
800
とある地方技術勉強会に集うエンジニアたちのこれまでとこれから
pharaohkj
1
180
2026年、書籍をちゃんと読むぞ👊 〜約3万円分の書籍を積読にしないためにやること〜
subroh0508
5
900
JAWS-UG/AWS Community Update - JAWS-UG栃木 #6
awsjcpm
0
140
蓮ノ空女学院スクールアイドルクラブはなぜ強いのか
subroh0508
0
110
5年間ぐらい、 スプリントレトロスペクティブは、 「+/Δ」しかしてないので、 あらためて良いのか悪いか考えてみる / Doing Plus Delta for about five years
camel_404
1
470
251011「ひとりより、みんなで!」 九州の支部で始めた、新しい連携のかたち
east_takumi
2
180
Featured
See All Featured
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
66
57k
New Earth Scene 8
popppiees
3
2.5k
Prompt Engineering for Job Search
mfonobong
0
400
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.2k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
430
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
The Cult of Friendly URLs
andyhume
79
7k
Product Roadmaps are Hard
iamctodd
55
12k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
250
Paper Plane
katiecoart
PRO
2
53k
Rails Girls Zürich Keynote
gr2m
96
14k
Transcript
Debugging and Profiling Rails App David Paluy January 2013
None
Ruby is eating RAM
Agenda • “Winter is coming!” • Garbage Collector • Debug
Tools • Profiling Tools
The Task: Send ~30,000 e-mails
Result Before
How Ruby Works? Physical RAM Process Heap Ruby Heap Ruby
Heap Ruby Object Ruby Object Ruby Object Ruby Object Ruby Object Ruby Object
New Object allocation Free List A L L O C
A T E D F R E E
New Object allocation Free List A L L O C
A T E D
New Object allocation Free List is empty A L L
O C A T E D
New Object allocation Free List is empty – Call GC
A L L O C A T E D
GC Process • GC finds non-reachable objects and adds them
to Free List • If Free List is still empty, another Heap allocated
MRI GC • “Conservative”: any bit pattern could be a
pointer (may produce false positive) • “Stop the world”: no other Ruby code can execute during GC • “Mark & Sweep”: mark all objects in use, than sweep away unmarked objects
More Objects => Longer GC => Slow
In our case – Out of Memory!
How to Debug? • gem "pry-debugger" https://github.com/nixme/pry-debugger • gem "debugger-pry"
https://github.com/pry/debugger-pry
Tools • ObjectSpace.count_objects • GC debug - Enable heap dump
support • gdb.rb (only Linux) Note: memprof works only with Ruby 1.8
ObjectSpace.count_objects
Enable heap dump support to Ruby Install custom patched version
of ruby Usage:
https://github.com/tmm1/gdb.rb Attached to existing process and examine the HEAP
Result After
Profiling Tools • Ruby Benchmark • ruby-prof • perftools.rb (Google
perftools for Ruby)
Benchmark • gem 'benchmark_suite' https://github.com/evanphx/benchmark_suite
ruby-prof gem 'ruby-prof' https://github.com/rdp/ruby-prof
ruby-prof Measurements • process time (RubyProf::PROCESS_TIME) • wall time (RubyProf::WALL_TIME)
• cpu time (RubyProf::CPU_TIME) • object allocations (RubyProf::ALLOCATIONS) • memory usage (RubyProf::MEMORY) • garbage collections runs (RubyProf::GC_RUNS) • garbage collection time (RubyProf::GC_TIME)
perftools.rb https://github.com/tmm1/perftools.rb gem 'rack-perftools_profiler', :require => 'rack/perftools_profiler'
rack-perftools_profiler usage
KCacheGrind
Summary • More Objects => Longer GC => Slow •
Examine your HEAP • Use Tools
Q&A http://dpaluy.github.com @dpaluy
[email protected]
http://www.linkedin.com/in/davidpaluy