Skip to content

vm_backtrace.c: let rb_profile_frames show cfunc frames#3299

Merged
mame merged 1 commit intoruby:masterfrom
mame:rb_profile_frames-show-cfunc-frames
Jul 28, 2020
Merged

vm_backtrace.c: let rb_profile_frames show cfunc frames#3299
mame merged 1 commit intoruby:masterfrom
mame:rb_profile_frames-show-cfunc-frames

Conversation

@mame
Copy link
Copy Markdown
Member

@mame mame commented Jul 8, 2020

... in addition to normal iseq frames.
It is sometimes useful to point the bottleneck more precisely.

An example code:

N = 100_000
M = 100_000
def foo
  open("/dev/zero") do |inp|
    open("/dev/null", "w") do |out|
      N.times do
        data = inp.read(N)
        out.write(data)
      end
    end
  end
end

stackprof --d3-flamegraph before the patch:
image

stackprof --d3-flamegraph after the patch:
image

... in addition to normal iseq frames.
It is sometimes useful to point the bottleneck more precisely.
@mame
Copy link
Copy Markdown
Member Author

mame commented Jul 8, 2020

@mame mame merged commit da31900 into ruby:master Jul 28, 2020
else {
cme = rb_vm_frame_method_entry(cfp);
if (cme && cme->def->type == VM_METHOD_TYPE_CFUNC) {
buff[i] = (VALUE)cme;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to handle the start argument. Although, it was already effectively being ignored (https://bugs.ruby-lang.org/issues/14607). I've updated #2713 to also fix the handling of the start argument for this branch.

ivoanjo added a commit to ivoanjo/backtracie that referenced this pull request Mar 13, 2021
A few specs are still broken, but overall it seems to be close to
working, **including what is effectively a backport of Ruby 3.0's
addition of cfunc frames to this API**
(<ruby/ruby#3299>)!.
aprocter-stripe added a commit to sorbet/sorbet that referenced this pull request Jul 30, 2021
The patch is simply a cherry-pick of ruby/ruby#3299.
This will allow us to see cfunc frames (e.g., Kernel#puts) in
StackProf traces.
ivoanjo added a commit to DataDog/dd-trace-rb that referenced this pull request May 4, 2022
…bies

Ruby 3.0 finally added support for showing CFUNC frames (frames for
methods written using native code) in stack traces gathered via
`rb_profile_frames` (ruby/ruby#3299).

To access this information on older Rubies, beyond using our custom
`ddtrace_rb_profile_frames`, we also need to backport the Ruby 3.0+
version of `rb_profile_frame_method_name`.
ivoanjo added a commit to DataDog/dd-trace-rb that referenced this pull request May 18, 2022
…bies

Ruby 3.0 finally added support for showing CFUNC frames (frames for
methods written using native code) in stack traces gathered via
`rb_profile_frames` (ruby/ruby#3299).

To access this information on older Rubies, beyond using our custom
`ddtrace_rb_profile_frames`, we also need to backport the Ruby 3.0+
version of `rb_profile_frame_method_name`.
ivoanjo added a commit to DataDog/dd-trace-rb that referenced this pull request May 20, 2022
…bies

Ruby 3.0 finally added support for showing CFUNC frames (frames for
methods written using native code) in stack traces gathered via
`rb_profile_frames` (ruby/ruby#3299).

To access this information on older Rubies, beyond using our custom
`ddtrace_rb_profile_frames`, we also need to backport the Ruby 3.0+
version of `rb_profile_frame_method_name`.
ivoanjo added a commit to DataDog/dd-trace-rb that referenced this pull request May 23, 2022
…bies

Ruby 3.0 finally added support for showing CFUNC frames (frames for
methods written using native code) in stack traces gathered via
`rb_profile_frames` (ruby/ruby#3299).

To access this information on older Rubies, beyond using our custom
`ddtrace_rb_profile_frames`, we also need to backport the Ruby 3.0+
version of `rb_profile_frame_method_name`.
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.

2 participants