Using ruby-prof, not seeing most of my own method/object names

81 views
Skip to first unread message

Grant Schoep

unread,
Jun 6, 2014, 5:01:30 PM6/6/14
to ruby-opt...@googlegroups.com
Using Ruby 2.1.0p0, ruby-prof-0.15.1, RHEL 5.10

So I have a Ruby script, which calls a lot of my own internal class and code. I'm now trying to profile it.

I can generate flat and graph reports, However, when I search through the output, I rarely find any of my own objects/methods or anything. I see lots of the calls I make that exist in gems (OCI8, nokogiri) but I am not seeing nice references to my objects that are calling it.  Sure, I can see the top level script references, but the whole "in-between" seems missing. i.e. All my classes and stuff in between my "main" script, and the gems/ruby core.

Do I need to do something special for ruby-prof to "understand" the classes I am calling?

Thanks

rogerdpack

unread,
Jun 6, 2014, 5:56:31 PM6/6/14
to ruby-opt...@googlegroups.com
How are you profiling it?
What classes/methods do you want to see, what is an example output that shows their absence? (I wonder if there's some "minimum percent used" option or something that is preventing them from showing up...)

Grant Schoep

unread,
Jun 6, 2014, 6:24:39 PM6/6/14
to ruby-opt...@googlegroups.com
I just added  the following to the begining of my script

require 'ruby-prof'
RubyProf.start

And then add this to the end of my script.

printer = RubyProf::FlatPrinter.new(result)
#printer = RubyProf::GraphPrinter.new(result)
outputFile = File.open("blah32", 'w')
printer.print(outputFile)
outputFile.close()

Tried FlatPrinter and GraphPrinter

I'm not doing any other settings to change mimumum percent used or anything.

I would expect the class's and methods that I am calling to show up. Meaning, my APP_HOME has a rubylib directory. In that directory, I have a bunch of .rb files that are classes to do different things. I am create new objects based off those classes.

I add those classes to my path via $LOAD_PATH ( I tried adding them via RUBYLIB varibale as well, no difference)

Roger Pack

unread,
Jun 7, 2014, 9:21:33 AM6/7/14
to ruby optimization
(I assume result is calculated at the end there).  Do you actually run things in those classes you mentioned?


--

---
You received this message because you are subscribed to the Google Groups "ruby optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-optimizat...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Grant Schoep

unread,
Jun 8, 2014, 1:45:56 AM6/8/14
to ruby-opt...@googlegroups.com
Ah, I figured out the issue, give me a night to sleep on it and think
about more things.

When I first started running my app with ruby-prof, It was crashing
with "stack level too deep". I googled the issue and found this
solution to the crash.

RubyVM::InstructionSequence.compile_option = {
:tailcall_optimization => true,
:trace_instruction => false
}

That made it run fine, but, that "trace_instruction" was the cause of
the missing info, makes sense now.

Interestingly enough, I also found the culprit of the "stack level too deep"

I was using
$LOAD_PATH.insert(0,ENV['APP_HOME'] + '/rubylib')
which was causing the crash. I commented that out, and added that path
to the shell via the RUBYLIB variable, and presto, the stack level too
deep crash went away.

Thanks for your help all.

Grant Schoep

unread,
Jun 8, 2014, 1:45:56 AM6/8/14
to ruby-opt...@googlegroups.com
Ah, give me a night to sleep on it and look again. I figured out the issue. When I first started running my app with ruby_prof, it was crashing with "stack level too depp". I googled it and had added the following to my code


Grant Schoep

unread,
Jun 8, 2014, 12:51:06 PM6/8/14
to ruby-opt...@googlegroups.com
Sorry for the partial post, somehow accidentally hit send. 

Anyways, with regards to the "stack level to deep" I also determined there was no difference with $LOAD_PATH versus RUBYLIB. I think I forgot to change my dataset on that test. Further runs showed no difference between the two. Which makes sense.  

Roger Pack

unread,
Jun 9, 2014, 2:26:02 AM6/9/14
to ruby optimization
i wonder how that caused a recursion issue...hmm...


--
Reply all
Reply to author
Forward
0 new messages