TvE 2100

At 2100 feet above Santa Barbara

Ruby-prof Does Not Play Nice With Threads

… or so it seems! I was trying to profile a worker running in BackgrounDRb and I kept getting errors almost as soon as I’d call RubyProf.start looking like this:


./script/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/inflector.rb:108: warning: ruby-prof: An error occured when leaving the method Inflector#singularize.
   Perhaps an exception occured in the code being profiled?

Each time the error would occur in a slightly different place. I finally disabled all but one worker (thread) and that seems to have fixed the problem.

Update: it seems that it is possible to use ruby-prof with threads, but it looks like one has to start the profiling before forking off the threads.