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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
41
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
230
How to Prepare 3 min Fundraising Presentation
dpaluy
0
1k
Other Decks in How-to & DIY
See All in How-to & DIY
「無理」を「コントロール」するスキル / Skills to Control "Muri"
hageyahhoo
6
4.2k
人見知りな HUB おじさんが 会話のハードルを超え、 今度は誰かの踏み台になろうとする話/hub-guy-as-a-stepping-stone
aokiplayer
2
210
AWSコミュニティプログラムのご紹介 -グローバル展開するコミュニティプログラム-
awsjcpm
0
350
JAWS-UG/AWSコミュニティプログラムのご紹介 (JAWS-UG広島)
awsjcpm
1
150
なぜJAWS-UGはこんなにも活発なのか?
awsjcpm
1
240
猟銃所持許可を取ってみた
kenkino
2
160
5年間ぐらい、 スプリントレトロスペクティブは、 「+/Δ」しかしてないので、 あらためて良いのか悪いか考えてみる / Doing Plus Delta for about five years
camel_404
1
440
家を建てて学ぶPjM
rinkei
0
160
JAWS-UG/AWS Communities Updates 2025/11/8 JAWS-UG 島根支部
awsjcpm
1
160
とある地方技術勉強会に集うエンジニアたちのこれまでとこれから
pharaohkj
1
160
JAWS-UG/AWSコミュニティ -JAWS-UGくまもと#16
awsjcpm
1
230
How to make the Groovebox
asonas
2
2.2k
Featured
See All Featured
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
440
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.5k
Mobile First: as difficult as doing things right
swwweet
225
10k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.3k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
How to build a perfect <img>
jonoalderson
1
5.7k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
320
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
390
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.1k
It's Worth the Effort
3n
188
29k
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