Garbage Collection and the Ruby Heap
Location: Room 309- 310
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:
- finding reference leaks in ruby:
- reducing memory usage and overhead:
Copy-on-Write GC / REE,
- finding C extension memory leaks:
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.
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 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.