On Oct 8, 2011, at 4:05 PM, SASADA Koichi wrote:

> (2011/10/09 1:54), Perry Smith wrote:
>> Would it be plausible to somehow, get the (ruby) stack of the running =
ruby process (or a particular thread), periodically?  For example, every =
10 seconds.
>>=20
>> 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).
>>=20
>> The overall objective is to have a very light weight (low impact) =
technique for profiling a Rails app as it is running in production.  =
Over the course of a week, for example, gather enough statistics to =
understand where the app is spending the most time.
>>=20
>> Of course, the other question is: has this already been done?  (I =
couldn't find anything.)
>=20
> Generally, it should say "Sampling profiling".

Ok.  That works for me.  The general technique is not new.  I just can't =
find an implementation for Ruby.

Here is a specific reference to the general technique:
=
http://en.wikipedia.org/wiki/Profiling_%28computer_programming%29#Statisti=
cal_profilers

This mentions "gprof" which is where I got the original idea from.

> We can do it for several information.  You say "get the current stack
> for a particular thread".  What do you want to do with stack?  =
Sampling
> "performance" profiling?
>=20
> I want to know "What you want" instead of "How you want".
> After that, we can consider "how we do it".

What I was thinking is to gather and record the full stack trace every =
10 seconds (to use my original example).  Once a week's worth of data =
has been collected, it could be analyzed to find which stacks came up =
the most often and that would tell me where the program is spending most =
of the time.

Thank you for helping.  Let me know if I'm still not clear and I'll try =
again.

pedz