Forum: JRuby [Q] print all ruby thread stacks?

Posted by Chuck Remes (cremes)
on 2010-03-06 18:16
(Received via mailing list)
I am trying to debug a ruby program that periodically hangs when run 
under jruby. It runs okay under MRI (1.8.7 and 1.9.1).

Is there a way for me to install a signal handler that prints all of the 
thread callstacks and exits? This would help me pinpoint where in the 
code it is hanging.

I was thinking something along the lines of this:

# need to use ABRT since jruby doesn't see a ctrl-c and I need to send 
it
# a kill -9 to exit
trap 'ABRT' do
  @threads.each do |thread|
    # print callstack?
  end
end

I'd appreciate any help in this matter. Thank you...

cr


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Thomas E Enebo (Guest)
on 2010-03-06 19:07
(Received via mailing list)
control-\ should dump all the stacks. Can that work or is this a daemon?

-Tom

On Sat, Mar 6, 2010 at 11:15 AM, Chuck Remes <cremes.devlist@mac.com> 
wrote:
>                # print callstack?
>
>    http://xircles.codehaus.org/manage_email
>
>
>



--
blog: http://blog.enebo.com       twitter: tom_enebo
mail: tom.enebo@gmail.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Chuck Remes (cremes)
on 2010-03-06 19:49
(Received via mailing list)
On Mar 6, 2010, at 12:06 PM, Thomas E Enebo wrote:

>> 
>> # need to use ABRT since jruby doesn't see a ctrl-c and I need to send it
>> # a kill -9 to exit
>> trap 'ABRT' do
>>        @threads.each do |thread|
>>                # print callstack?
>>        end
>> end
>> 
>> I'd appreciate any help in this matter. Thank you...

I tried to interrupt it in the shell with control-\ but it is still 
hung. The only way I can kill it is with a -9.

Maybe the entire interpreter is hanging. I'm kind of stuck and don't 
know how to interrupt its execution and still get any relevant data.

cr



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Chuck Remes (cremes)
on 2010-03-06 19:55
(Received via mailing list)
On Mar 6, 2010, at 12:48 PM, Chuck Remes wrote:

>>> Is there a way for me to install a signal handler that prints all of the thread callstacks and exits? This would help me pinpoint where in the code it is hanging.
>>> 
>>> I'd appreciate any help in this matter. Thank you...
> 
> I tried to interrupt it in the shell with control-\ but it is still hung. The only way I can kill it is with a -9.
> 
> Maybe the entire interpreter is hanging. I'm kind of stuck and don't know how to interrupt its execution and still get any relevant data.

I just tried attaching to the process using jvisualvm (this is on OSX 
10.6.2 running JRuby 1.4.0 release and the 64-bit JVM).

Jvisualvm was unable to attach so I couldn't do a thread dump or heap 
dump. Something is getting majorly hosed here...

cr


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Chuck Remes (cremes)
on 2010-03-06 20:57
(Received via mailing list)
Running my code against 1.5.0-dev (head) never hangs. However, I do run 
into that #map bug that I've written about in another thread. I now have 
a little workaround for that so I can successfully run my code against 
head.

Nevermind!

cr


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by James Abley (Guest)
on 2010-03-08 19:07
(Received via mailing list)
Kill -3 {pid} is another way of getting thread dumps.

Cheers,

James

On 6 Mar 2010 19:57, "Chuck Remes" <cremes.devlist@mac.com> wrote:


Running my code against 1.5.0-dev (head) never hangs. However, I do run 
into
that #map bug that I've written about in another thread. I now have a 
little
workaround for that so I can successfully run my code against head.

Nevermind!


cr
Posted by Daniel Lucraft (Guest)
on 2010-03-13 12:13
(Received via mailing list)
jruby-prof 0.1
==============

This is a clone of ruby-prof for JRuby. It supports all the usual output 
modes, plus a call tree output mode.  The only measure mode it currently 
supports is wall time.

*** NB. This is really new code. It probably has lots of bugs and 
things. ***

I wrote a blog post about it here: 
http://danlucraft.com/blog/2010/03/jruby-prof/

Please try it out and let me know if it doesn't work for you!

INSTALL
-------

    $ jruby -S gem install jruby-prof


SOURCE
------

    http://github.com/danlucraft/jruby-prof


USAGE
-----

In your program:

    require 'rubygems'
    require 'jruby-prof'

    result = JRubyProf.profile do
      # my stuff
    end

    JRubyProf.print_flat_text(result, "flat.txt")
    JRubyProf.print_graph_text(result, "graph.txt")
    JRubyProf.print_graph_html(result, "graph.html")
    JRubyProf.print_call_tree(result, "call_tree.txt")
    JRubyProf.print_tree_html(result, "call_tree.html")

In order to tell JRuby to send events to JRubyProf for processing, you 
must
run your script with the debug flag on:

    $ jruby --debug my_script.rb


Thanks,
Dan

_______________________________
Daniel Lucraft

twitter.com/danlucraft
danlucraft.com/blog


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Charles Nutter (headius)
on 2010-03-15 19:39
(Received via mailing list)
Hot diggity! Finally a nice Ruby-land profiler for JRuby!

If this looks good to everyone, it might be a nice one to
pre-install...or not? Maybe we can just leave it as a gem in the wild
and people can install it if they want to?

On Sat, Mar 13, 2010 at 5:12 AM, Daniel Lucraft <danlucraft@me.com> 
wrote:
>
>
>      # my stuff
>
> danlucraft.com/blog
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Chuck Remes (cremes)
on 2010-03-15 19:42
(Received via mailing list)
On Mar 15, 2010, at 1:38 PM, Charles Oliver Nutter wrote:

> Hot diggity! Finally a nice Ruby-land profiler for JRuby!
> 
> If this looks good to everyone, it might be a nice one to
> pre-install...or not? Maybe we can just leave it as a gem in the wild
> and people can install it if they want to?

I always prefer non-core stuff as a gem.

My 0.02

cr


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.