I'm not an expert on Ruby optimization, but have you looked at
perftools.rb? It says that it's a sampling profiler with minimal
overhead.

https://github.com/tmm1/perftools.rb

Andrew

On Tue, Oct 11, 2011 at 3:29 AM, Roger Pack <rogerdpack2 / gmail.com> wrote:
>> Would it be plausible to somehow, get the (ruby) stack of the running ru=
by process (or a particular thread), periodically? =A0For example, every 10=
 seconds.
>>
>> One approach might be to have a separate thread with a timer that popped=
 and it would get the current stack for a particular thread (not itself).
>>
>> The overall objective is to have a very light weight (low impact) techni=
que for profiling a Rails app as it is running in production. =A0Over the c=
ourse of a week, for example, gather enough statistics to understand where =
the app is spending the most time.
>>
>> Of course, the other question is: has this already been done? =A0(I coul=
dn't find anything.)
>
> I don't think it has. =A01.9.x provides you a Thread#backtrace so it
> should be possible just using that. =A0I've been meaning to incorporate
> it into the
> ruby-prof gem, and will put it on the backlog...
> https://github.com/danielhoey/ruby-prof might already do it.
> -r
>
>