jruby / jruby-rack

Rack for JRuby and Java appservers
MIT License
397 stars 137 forks source link

Can't get --profile.api to work. #158

Closed mikesnare closed 11 years ago

mikesnare commented 11 years ago

Any time I try, I'm getting empty output. I.e., there's output, and it's in the correct format, but there's no meaningful data in it. This is happening in a rails app (in a controller) as well as in the rails console (technically pry)

[20] pry(main)> profile_data = JRuby::Profiler.profile do
[20] pry(main)*   # code to be profiled:
[20] pry(main)*   [*50..1000].collect {|val| val = val + 10}
[20] pry(main)* end
=> #<Java::OrgJrubyRuntimeProfile::ProfileData:0x7b09519b>
[21] pry(main)> JRuby::Profiler::FlatProfilePrinter.new(pd).printProfile(STDOUT)
Total time: 0.00

     total        self    children       calls  method
----------------------------------------------------------------
=> nil
[22] pry(main)>
kares commented 11 years ago

Hey Mike, thanks - you need to "turn profiling on", did you do that ? Currently this is not officially supported but when you set the jruby.runtime.arguments parameter to --profile it should do somethings, otherwise the runtime does not collect invocation data. If it does not work it's likely an old issue with JRuby - it was designed to handle profiling a single "main" runtime while we do things differently - there's an attempt https://github.com/jruby/jruby/pull/240 that should handle this (latest JRuby 1.7.x) but it's been a while since I worked on that not sure if there's (still) anything missing to get it working ...

mikesnare commented 11 years ago

Perfect. I was going to say that that should really be documented somewhere, but it looks like it's already been asked for in #130.

Interestingly, though, --profile.api seems to work (at least as far as the CLI output is concerned) because one of the first messages I get is this:

Profiling enabled; ^C shutdown will now dump profile info

...and that's whether I use --profile.api or the runtime arguments. Regardless, thanks for the help. I'll close this issue.

kares commented 11 years ago

Thanks Mike, yes it will enable profiling - the question is if you see "real" (accurate) profiling data and not some non-sense (from the main runtime). If you're threadsafe! and using e.g. Warbler it will likely work but might not for other setups (e.g. Trinidad). Maybe if you do some profiling and see some data that look good, you can share the setup of yours here so for others we know what does work ... would be appreciated.