DTrace for Ruby is available

In previous posts we’ve mentioned we’re working on a full Ruby DTrace provider set for Ruby 1.8.5. We’ve finished a solid base set of probes and it is ready for general consumption.

The subversion repository is at http://svn.joyent.com/ruby-dtrace.

The repository contains:

There are 3 binaries for Solaris provided here:

  1. ruby-x86: Standard GCC build
  2. ruby-CSK: Coolstack compliant build intended to drop into Coolstack 1.1
  3. ruby-CSW: Blastwave drop-in binary

The warning regarding the ruby-CSW binary is that it breaks with Blastwave tradition of using Sun Studio. Instead, GCC (/usr sfw) was used, due to various build issues with Ruby 1.8.5 and Sun Studio that are not related to the DTrace patch. The build name has been changed to Solaris 2.8 to ensure that extensions continue to work. You’re better off using the csw binary for debugging only until we can get a fully compliant build (coming real real soon).


The probes that are currently in Ruby-DTrace

Probe name          Description
function-entry      Probe that fires when a Ruby method is entered.
function-return     Probe that fires when a Ruby method returns.
raise               Probe that fires when a Ruby exception is raised.
rescue              Probe that fires when a Ruby exception is rescued.
line                Probe that fires for every line of Ruby executed.
gc-begin            Probe that fires right before a GC cycle begins.
gc-end              Probe that fires right after a GC cycle finishes.
object-create-start Probe that fires directly before a Ruby object is allocated.
object-create-done  Probe that fires when Ruby is finished allocating an object
object-free         Probe that fires every time a Ruby object is freed.
ruby-probe          Probe that can be fired from Ruby code (see below).


Probe               args[0]            args[1]       args[2]       args[3]
function-entry      Ruby class         Method name   Source file   Line number
function-return     Ruby class         Method name   Source file   Line number
raise               Ruby class         Source file   Line number   -
rescue              Source file        Line number   -             -
line                Source file        Line number   -             -
gc-begin            -                  -             -             -
gc-end              -                  -             -             -
object-create-start Ruby type          Source file   Line number   -
object-create-done  Ruby type          Source file   Line number   -
object-free         Ruby type          -             -             -
ruby-probe          Arbitrary string   -             -             -

Ruby Tracer Module

Included with the patch is a built-in Ruby module called Tracer. Tracer provides one method, Tracer.fire(str), which will fire the ruby-probe, setting args[0] to the string you pass in.

We will continue to add and refine probes, will be blogging about some more examples, and we are accepting requests for additional probe points (just email jason at joyent dot com). We will be developing patches against 1.8.6 in the near future.

7 responses to “DTrace for Ruby is available”

  1. nice work scott

  2. Wow, that’s cool. Worth running Solaris (even if inside a vm) just for profiling Ruby/Rails apps. Thanks!

  3. For the love of all that is holy, please get this to work on Leopard.

  4. > For the love of all that is holy, please get this to work on Leopard.


  5. Stay tuned 🙂

  6. Nice work guys, keep it up.

  7. Is it me or are the binaries available above only for Solaris x86. I’m running Solaris 10 (SPARC) with the CoolStack 1.1 version of Ruby but this does not appear to have any DTrace probes in it.

    I tried downloading the ruby-CSK binary above but like I said, it appears to be an x86 file.

    Is a SPARC binary for ruby-CSK available?

%d bloggers like this: