Garbage Collection and the Ruby Heap

Aman Gupta (GitHub), Joe Damato (Boundary)
General
Location: Room 309- 310
Average rating: ****.
(4.43, 58 ratings)

The talk will start out with a brief overview of stacks vs heaps, and various garbage collection algorithms. We’ll explain the details of the MRI implementation of ruby heap (10k initial slots, grows by 1.8x each time, linked list of free slots) and garbage collector (stop the world mark-and-sweep collector, scans the C stack, triggered by 8mb malloc_limit and rb_newobj).

After explaining the basics, we’ll focus on specific examples and show off a variety of tools and patches:

  • understanding and tuning the GC:
    ObjectSpace statistics,
    RAILSBENCH
  • finding reference leaks in ruby:
    BleakHouse,
    GC.dump_heap
  • reducing memory usage and overhead:
    Copy-on-Write GC / REE,
    tcmalloc
  • finding C extension memory leaks:
    valgrind,
    google-perftools heap profiler

We’ll also highlight common tricks for improving the performance of ruby code running under MRI by reducing the memory overhead:

  • store commonly used strings in constants instead of using them inline
  • use symbols instead of strings
  • invoke GC after large allocations
  • disable GC during time sensitive operations

Finally we’ll look ahead to ruby 1.9 and jruby and talk about how they fix some of these issues in MRI.

Photo of Aman Gupta

Aman Gupta

GitHub

Aman is a serial entrepreneur, ruby hacker and a recent winner of a Ruby Heroes award. He currently maintains the EventMachine project and various other gems that help build high-performance distributed and asynchronous systems in ruby, including em-mysql, em-spec, jsSocket and amqp.

Most recently, Aman has been hacking on performance improvements to MRI, releasing several patches to ruby and perftools.rb, a sampling profiler for ruby code based on google-perftools.

Joe Damato

Boundary

Joe Damato is a hacker who focuses on the low level implications of Ruby including I/O, performance, testing, and scaling. He maintains a blog (http://timetobleed.com) where he releases code, patches to the Ruby interpreter, and his thoughts about low level systems programming. He has submitted a few patches to Ruby core, the most interesting of which is a bug-fix to the threading implementation in Ruby 1.8 and a Fibers implementation for Ruby 1.8 that he worked on with Aman Gupta. He also added libdl support to ltrace to allow tracing library functions which are linked at runtime (such as Ruby gems).

Comments on this page are now closed.

Comments

Derek Croft
06/17/2010 10:03am EDT

This was the first talk I attended that addressed topics at a super-technical level, and it was very interesting and very well presented. Also, memprof is an amazing tool!

Picture of Darren Hinderer
Darren Hinderer
06/11/2010 4:56pm EDT

Very engaging for the depth of technical detail you were going through, and appreciated that you shared your REE config data too.

Picture of Mike Subelsky
Mike Subelsky
06/10/2010 11:14am EDT

your hard work shone through this whole talk; I appreciated the advanced level discussion that was still accessible to me, an intermediate-level Rubyist and a novice to OS programming

Gregg Ganley
06/08/2010 2:36pm EDT

great talk!! awesome tools, can’t wait to try them!

Thank you

Derek Kaczmarczyk
06/08/2010 2:29pm EDT

great talk

co-presented by Ruby Central, Inc. O'Reilly
  • Engine Yard
  • Heroku
  • 8th Light
  • Blue Box Group
  • InfoEther
  • JetBrains
  • New Relic
  • Open Hosting
  • Rhomobile
  • WyeWorks
  • Linux Pro Magazine
  • Chargify

Sponsorship Opportunities

For information on exhibition and sponsorship opportunities at RailsConf, contact Yvonne Romaine at yromaine@oreilly.com.

Download the RailsConf Sponsor/Exhibitor Prospectus

Media Partner Opportunities

For information on trade opportunities with O'Reilly conferences or contact mediapartners@ oreilly.com

Program Ideas

Send us your suggestions for speakers, topics, and activities to rails-idea@oreilly.com.

Press and Media

For media-related inquiries, contact Maureen Jennings at maureen@oreilly.com.

RailsConf Newsletter

To stay abreast of conference news please sign up for the RailsConf newsletter (login required)

Contact Us

View a complete list of RailsConf 2010 contacts.