Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not appear Array#<< result. #132

Closed
SpringMT opened this issue Dec 21, 2013 · 3 comments
Closed

Not appear Array#<< result. #132

SpringMT opened this issue Dec 21, 2013 · 3 comments

Comments

@SpringMT
Copy link

I got the profile below script.
https://gist.github.com/SpringMT/8068584

When use profile, Array#<< result appeared.
https://gist.github.com/SpringMT/8068598

However when use ruby-prof, Array#<< result didn't appear.
https://gist.github.com/SpringMT/8068605

I use ruby 2.0.0p353 and ruby-prof 0.13.1.

@skaes
Copy link
Member

skaes commented Dec 23, 2013

The discrepancy is caused by the ruby byte code compiler and the way trace events are generated.

For some method invocations, ruby generates shorter byte code. << is one of those methods. The code path in the interpreter does not generate trace events for optimized calls.

The profiler you load using -r profile, gets around these limitations by setting a compile flag to not use the optimized method calls but to generate the default code sequence (which does generate trace events when run).

The following option settings can be used to require unoptimized code generation:

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

@SpringMT
Copy link
Author

👍

I add below code in bin/ruby-prof

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

And I run the code (https://gist.github.com/SpringMT/8068584).

Appear Array#<< result !
https://gist.github.com/SpringMT/8098996

Thank you!

skaes added a commit to skaes/ruby-prof that referenced this issue Dec 25, 2013
@skaes
Copy link
Member

skaes commented Dec 25, 2013

Turns out that ruby-prof was already trying to mimic profiler, but it used the wrong constant for the ruby vm (VM instead of RubyVM).

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

No branches or pull requests

2 participants