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
46
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
JAWS-UG/AWSコミュニティプログラムのご紹介 (JAWS-UG広島)
awsjcpm
1
160
JAWS-UG/AWS Community Update - 2026/6/13 JAWS-UG TOHOKU 仙台
awsjcpm
0
1.2k
ライブ感を生む 巻き込み型スライドの作り方/Create your slide like a heavy metal concert
ikuodanaka
5
1.7k
JAWS-UG/AWSコミュニティプログラムのご紹介 - JAWS-UG 佐賀
awsjcpm
2
280
JAWS-UG 山梨 第10回 勉強会 Community Update
awsjcpm
0
1.1k
多摩ニュータウンを、 味わう
aokiplayer
2
730
フィールドエンジニア at 多摩川 / Field Engineer at Tamagawa
aokiplayer
0
360
いしかわ暮らしセミナー~知って安心!移住とお金講座~
matyuda
0
280
10分de名コミュ “最高の自分”を演じ憧れの同業者と渡り合う
subroh0508
1
670
終わりのない会議を超えて:HolacracyのTactical Meetingを体験しよう!
andrearc
0
320
「変えること」「変わること」を楽しむ力で"敵わない存在"と向き合う
subroh0508
2
1.8k
Nutanix Community Edition 超入門 25.04
ricefield66
0
440
Featured
See All Featured
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
460
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
680
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.1k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
190
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
460
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.1k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
360
Amusing Abliteration
ianozsvald
1
240
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
240
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
430
The Spectacular Lies of Maps
axbom
PRO
1
880
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
72
41k
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