Skip to content

Runtime profiling#96

Closed
kares wants to merge 5 commits intojruby:masterfrom
kares:runtime-profiling
Closed

Runtime profiling#96
kares wants to merge 5 commits intojruby:masterfrom
kares:runtime-profiling

Conversation

@kares
Copy link
Member

@kares kares commented Oct 28, 2011

This is my attempt to support "arbitrary" Ruby runtime profiling, as currently only profiling of the Ruby.getGlobalRuntime works as expected. The primary motivation for this would be profiling web applications running on top of jruby-rack jruby/jruby-rack#62.
Besides there's some "internal" profiling related refactorings, such as JRuby::Profiler.profile returns the full ProfileData (instead of the top Invocation). Printers are instantiated with a ProfileData argument e.g.

data = JRuby::Profiler.profile do
  ...
end
JRuby::Profiler::FlatProfilePrinter.new(data).printProfile(System.out)

The available profile specs are passing + there's a spec that makes sure all works for (non-global) instantiated runtimes. However, I must say I did not fully understand why the runtime needs to track the profiled methods (I thought tracking the invocations ProfileData.addProfiledMethod as they occur would be enough but it clearly isn't). I originally thought I would also accomplish user initiated profiling working only by a require 'jruby/profiler' and JRuby::Profiler.profile (without the need for a --profile argument).

If there's anything I did wrong, did not or could have done better I would love to hear from You guys.

@calavera
Copy link
Contributor

calavera commented Nov 1, 2011

It looks good to me. Perhaps @headius and @danlucraft can check it out because they have more experience than me.

@calavera
Copy link
Contributor

calavera commented Nov 1, 2011

@kares, have you thought about what could happen if the user doesn't have the JRuby version with this refactor but she uses the JRuby-rack version that supports it? I guess you should add a warning or something in the JRuby-rack side.

@kares
Copy link
Member Author

kares commented Nov 1, 2011

@calavera yes I have. currently it will "work" somehow, but you definitely won't see any method names (see the sample output in jruby/jruby-rack#62). as for the jruby-rack warning - the current changes for passing arguments are generic with no emphasis on --profile (despite the motivation of being able to profile web apps :)).
I was hoping, if it ever gets working with JRuby properly, that trinidad can than built a command line flag on top of it ...

@steveodom
Copy link

Would this also work for rack apps that aren't using jruby-rack? I'm running a basic sinatra app with JRuby. 'Arbitrary' profiling would be great for me as I'm trying to profile some code in this app but not sure how to pass in the required --profile flag.

@kares
Copy link
Member Author

kares commented Nov 28, 2011

@steveodom if you're not using jruby-rack this is most probably not necessary at all and should be entirely irrelevant for your case. jruby-rack boots separate Ruby runtimes (something like running a separate ruby process in MRI) to run your application code. thus you'll just need to find a way to pass the --profile flag while running the jruby executable (try exporting JRUBY_OPTS="--profile").
ask on a forum/irc/stackoverflow with the details about your setup and someone will surely point you the right direction ...

@BanzaiMan
Copy link
Member

I really hate to close this request, but this request is too old and too large at this time to consider merging.

The idea is intriguing, however. Do you mind retrying for the current code base?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants