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
Say what particular C function is being sampled #110
Comments
Yeah, I think I might give this a shot! Can you send me a flamegraph of what you're seeing? i'd be curious to see what it looks like. |
Uploaded the flamegraph, but the 60% number comes from the summary that you print out while sampling |
thanks! I think what's going on in your case (and this is likely to be true for a lot of people) is that there are a lot of different C functions being called, but they're all aggregated together because rbspy can't tell that they're different and so it looks weird. I wonder if (as a start) it would make sense to just exclude C functions from the summary because it's so uninformative and instead just report whatever Ruby function is closest to the top of the stack. |
I think that would be much more helpful! |
if (cfp->iseq != 0) { ... }
else if ((me = rb_vm_frame_method_entry(cfp)) != NULL) {
iseq_name = rb_id2name(me->def->original_id);
snprintf(posbuf, MAX_POSBUF, ":%s", iseq_name);
line = -1;
} with const rb_callable_method_entry_t *
rb_vm_frame_method_entry(const rb_control_frame_t *cfp)
{
VALUE *ep = cfp->ep;
rb_callable_method_entry_t *me;
while (!VM_EP_LEP_P(ep)) {
if ((me = check_method_entry(ep[-1], FALSE)) != NULL) return me;
ep = VM_EP_PREV_EP(ep);
}
return check_method_entry(ep[-1], TRUE);
} I know next to nothing of Ruby VM internals, but maybe this isn't too hard to implement. Unfortunately, I don't know Rust so I can't help. I also wonder what the point of using Rust for this project is, since it prevents straightforward usage of the C definitions in the Ruby source code. |
I tried
😥 |
@jvns @cataphract I tried to implement the logic of getting the c-level frame symbols. Actually, I just took it from .gdbinit and reimplement on rust. |
@ViugiNick Do you have a diff of your changes? Maybe I can can take a shot at it, though I don't know Rust. |
@cataphract @jvns https://gist.github.com/ViugiNick/583a55a73a515891f545e57653127def |
@AlexWayfer Me too even though #114 should have ensured that C functions are ignored in the summary? |
I have tried to use
|
@vizcay Try $ ruby -rrbconfig -e 'puts RbConfig::CONFIG["CFLAGS"]'
-O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC |
The code still needs a bit of polish, but I have this mostly working for ruby 2.7. Details in #282. Big thanks to @ViugiNick for the tip about porting the gdbinit functions. If anyone has time to give it a try, I'd be grateful for any feedback and testing help. |
I think this should be possible, at worst by reading the instruction pointer and walking back until you find a function?
This would be very helpful for me, since apparently I'm spending 60% of time in unknown C functions.
The text was updated successfully, but these errors were encountered: