ruby-prof 0.6.0 and Memory Profiling

Shugo and I are happy to announce the release of ruby-prof 0.6.0. If you haven’t used ruby-prof, its a superfast, open-source, profiler for Ruby that shows you where your program is slow.

The big news is that this release, thanks to Shugo, supports Ruby 1.9. And there is talk about merging ruby-prof into Ruby itself, but we’ll have to wait and see if that really happens.

This release also includes experimental support for memory profiling, added by Alexander Dymo, which I’ll talk about in more detail below. And of course it includes a number of bug fixes, almost all of which were reported and fixed by the community. Special thanks goes out to Sylvain Joyeux, Michael Granger, Makoto Kuwata and Dan Fitch.

The best way to get started with ruby-prof is to look at the readme file which is online at RubyForge.

Memory Profiling

The 0.5.0 release introduced the concept of measurement modes, which offer a way of extending ruby-prof to track all sorts of metrics about a running program, including time, object allocations, memory usage, etc. Developers can implement custom measurement modes by simply implementing a measurement function that tracks the metric of interest, and ruby-prof takes care of all the rest.

The idea was inspired by Sylvain Joyeux, who used it in the 0.5.0 release to track object allocations in a running program. In this release, Alexander Dymo added support for tracking memory allocations as I discussed in my last post.

The only disadvantage of these two measurement modes is that they require patched ruby interpreters, making them unavailable to most ruby developers. Tracking memory usage is particularly important, and there has been some great work done by Evan Weaver with BleakHouse, Erick Hodel with mem_inspect and Alexander Dymo. I’m not partial to any of these approaches, outside the fact they should be implemented in C for performance reasons. But I would like to see a single solution which could be merged into Ruby itself, opening it up to all Ruby developers.

I’ve asked Alexander to start up a discussion on ruby-core, so we’ll see where it leads.

Leave a Reply

Your email address will not be published. Required fields are marked *