Reputation: 168
Environment: Linux Mint 32 bit, JRuby-1.6.5 [ i386 ], Rails 3.1.3.
I am trying to profile my rails application deployed on JRuby 1.6.5 on WEBrick (in development mode).
My JRUBY_OPTS: "-Xlaunch.inproc=false --profile.flat"
In one of my models, I introduced an explicit sleep(5) and ensured that this method is called as part of before_save hook while saving the model. Pseudo code...
class Invoice < ActiveRecord::Base
<some properties here...>
before_save :delay
private
def delay
sleep(5)
end
end
The above code ensures that just before an instance of Invoice gets persisted, the method, delay is invoked automatically.
Now, when I profile the code that creates this model instance (through an rspec unit test), I get the following output:
6.31 0.00 6.31 14 RSpec::Core::ExampleGroup.run
6.30 0.00 6.30 14 RSpec::Core::ExampleGroup.run_examples
6.30 0.00 6.30 1 RSpec::Core::Example#run
6.30 0.00 6.30 1 RSpec::Core::Example#with_around_hooks
5.58 0.00 5.58 1 <unknown>
5.43 0.00 5.43 2 Rails::Application::RoutesReloader#reload!
5.00 0.00 5.00 1 <unknown>
5.00 5.00 0.00 1 Kernel#sleep
4.87 0.00 4.87 40 ActiveSupport.execute_hook
4.39 0.00 4.39 3 ActionDispatch::Routing::RouteSet#eval_block
4.38 0.00 4.38 2 Rails::Application::RoutesReloader#load_paths
In the above output, why do I see those two elements instead of Invoice.delay or something similar.
In fact, when I start my rails server (WEBrick) with the same JRUBY_OPTS (mentioned above), all my application code frames show up as unknown elements in the profiler output !
Am I doing anything wrong ?
Upvotes: 4
Views: 635
Reputation: 21
Looks like you max of the profile methods limit
Set -Xprofile.max.methods JRUBY_OPTS
to a big number (default is 100000 and is never enough). E.g.
export JRUBY_OPTS="--profile.flat -Xprofile.max.methods=10000000"
Upvotes: 2