I''m trying to put together a dtrace script that''ll track the hottest Ruby lines, but I''m afraid I''m far too much of a green n00b to even get started with such a task. I''m kind of surprised something along these lines doesn''t already exist, but I''m happy to release it once done. The plan is to use it to streamline the Merb framework in the run-up to 1.0 Thanks! -- Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20080619/47d87da3/attachment.html>
Brendan Gregg - Sun Microsystems
2008-Jun-19 21:43 UTC
[dtrace-discuss] Hottest Ruby Lines
G''Day, On Thu, Jun 19, 2008 at 12:58:04PM -0700, Yehuda Katz wrote:> > I''m trying to put together a dtrace script that''ll track the hottest > Ruby lines, but I''m afraid I''m far too much of a green n00b to even > get started with such a task. I''m kind of surprised something along > these lines doesn''t already exist, but I''m happy to release it once > done. > > The plan is to use it to streamline the Merb framework in the run-up > to 1.0The Ruby provider has been designed to make such tasks easy. It can count lines, which will catch many hot spots, with a one-liner: dtrace -n ''ruby*:::line { @calls[basename(copyinstr(arg0)), arg1] = count(); }'' It exists in the DTraceToolkit as a script, in case people start looking there, although the script only formats the output neatly: # rb_lines.d Tracing... Hit Ctrl-C to end. ^C FILE:LINE COUNT func_slow.rb:3 1 func_slow.rb:4 1 func_slow.rb:5 1 func_slow.rb:6 1 func_slow.rb:12 1 func_slow.rb:13 1 func_slow.rb:14 1 func_slow.rb:15 1 func_slow.rb:19 1 func_slow.rb:22 1 func_slow.rb:23 1 func_slow.rb:24 1 func_slow.rb:25 1 func_slow.rb:29 1 func_slow.rb:32 1 func_slow.rb:26 100000 func_slow.rb:27 100000 func_slow.rb:16 200000 func_slow.rb:17 200000 func_slow.rb:7 300000 func_slow.rb:8 300000 Untar the DTraceToolkit (http://freshmeat.net/projects/dtracetoolkit) and look for: /Ruby scripts /Examples/rb_*.txt example outputs from those scripts /Man/man1/rb_*.1 man pages /Code/Ruby example Ruby code for testing Brendan -- Brendan [CA, USA]
Brendan Gregg - Sun Microsystems wrote:> G''Day, > > On Thu, Jun 19, 2008 at 12:58:04PM -0700, Yehuda Katz wrote: > >> I''m trying to put together a dtrace script that''ll track the hottest >> Ruby lines, but I''m afraid I''m far too much of a green n00b to even >> get started with such a task. I''m kind of surprised something along >> these lines doesn''t already exist, but I''m happy to release it once >> done. >> >> The plan is to use it to streamline the Merb framework in the run-up >> to 1.0 >> > > The Ruby provider has been designed to make such tasks easy. It can > count lines, which will catch many hot spots, with a one-liner: >One other thing Yehuda, the guys who have done the Ruby work in OpenSolaris and the rest of the Web Stack project people would be interested in what the workflow looks like and what kind of data would best help you when trying to do this kind of optimization. This is an area we want to put some more time into and if you have any thoughts/contributions/questions, please bring it up on webstack-discuss at opensolaris.org> dtrace -n ''ruby*:::line { @calls[basename(copyinstr(arg0)), arg1] = count(); }'' > > It exists in the DTraceToolkit as a script, in case people start looking > there, although the script only formats the output neatly: > > # rb_lines.d > Tracing... Hit Ctrl-C to end. > ^C > FILE:LINE COUNT > func_slow.rb:3 1 > func_slow.rb:4 1 > func_slow.rb:5 1 > func_slow.rb:6 1 > func_slow.rb:12 1 > func_slow.rb:13 1 > func_slow.rb:14 1 > func_slow.rb:15 1 > func_slow.rb:19 1 > func_slow.rb:22 1 > func_slow.rb:23 1 > func_slow.rb:24 1 > func_slow.rb:25 1 > func_slow.rb:29 1 > func_slow.rb:32 1 > func_slow.rb:26 100000 > func_slow.rb:27 100000 > func_slow.rb:16 200000 > func_slow.rb:17 200000 > func_slow.rb:7 300000 > func_slow.rb:8 300000 > > Untar the DTraceToolkit (http://freshmeat.net/projects/dtracetoolkit) > and look for: > > /Ruby scripts > /Examples/rb_*.txt example outputs from those scripts > /Man/man1/rb_*.1 man pages > /Code/Ruby example Ruby code for testing > > Brendan > >