Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Debugging and Profiling Rails App

Debugging and Profiling Rails App

Overview of Debugging and Profiling tools for Rails

David Paluy

January 28, 2013
Tweet

More Decks by David Paluy

Other Decks in How-to & DIY

Transcript

  1. How Ruby Works? Physical RAM Process Heap Ruby Heap Ruby

    Heap Ruby Object Ruby Object Ruby Object Ruby Object Ruby Object Ruby Object
  2. GC Process • GC finds non-reachable objects and adds them

    to Free List • If Free List is still empty, another Heap allocated
  3. 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
  4. Tools • ObjectSpace.count_objects • GC debug - Enable heap dump

    support • gdb.rb (only Linux) Note: memprof works only with Ruby 1.8
  5. 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)
  6. Summary • More Objects => Longer GC => Slow •

    Examine your HEAP • Use Tools