-
Notifications
You must be signed in to change notification settings - Fork 12
[experiment, don't review] Reduce CallLogger tracing overhead by 8.4× #108
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
base: main
Are you sure you want to change the base?
Changes from all commits
4426b14
8443b16
b572503
964972c
f7adec9
65e5006
735c291
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,4 @@ lib/rotoscope/rotoscope.so | |
| .rubocop-* | ||
| Gemfile.lock | ||
| .bundle | ||
| coverage/ | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,49 +4,37 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <ruby/debug.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <stdbool.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| static VALUE caller_frame(int *line, bool ruby_call) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VALUE frames[2] = {Qnil, Qnil}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int lines[2] = {0, 0}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| static VALUE caller_frame(int *line) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VALUE frame = Qnil; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int frame_line = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // At this point, for ruby calls, the top ruby stack frame is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // for the method being called, so we want to skip that frame | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // and get the caller location. This is why we use 1 for ruby | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // calls. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // However, for C call, the top stack frame is for the caller, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // so we don't want to have to skip over any extra stack frames | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // for C calls. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int frame_index = ruby_call ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // For ruby calls, the top frame is the callee — skip it to get the caller. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Ruby 4.0+ fixed rb_profile_frames start argument (ruby-lang bug #14607). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rb_profile_frames(1, 1, &frame, &frame_line); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+12
to
14
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Ruby 4.0+ fixed rb_profile_frames start argument (ruby-lang bug #14607). | |
| rb_profile_frames(1, 1, &frame, &frame_line); | |
| // On older Rubies, rb_profile_frames(start, ...) may ignore start due to | |
| // ruby-lang bug #14607, so fetch from 0 and manually select the caller. | |
| #ifdef RUBY_API_VERSION_CODE | |
| #if RUBY_API_VERSION_CODE >= 40000 | |
| rb_profile_frames(1, 1, &frame, &frame_line); | |
| #else | |
| VALUE frames[2] = {Qnil, Qnil}; | |
| int lines[2] = {0, 0}; | |
| int collected = rb_profile_frames(0, 2, frames, lines); | |
| if (collected >= 2) { | |
| frame = frames[1]; | |
| frame_line = lines[1]; | |
| } else if (collected == 1) { | |
| frame = frames[0]; | |
| frame_line = lines[0]; | |
| } | |
| #endif | |
| #else | |
| VALUE frames[2] = {Qnil, Qnil}; | |
| int lines[2] = {0, 0}; | |
| int collected = rb_profile_frames(0, 2, frames, lines); | |
| if (collected >= 2) { | |
| frame = frames[1]; | |
| frame_line = lines[1]; | |
| } else if (collected == 1) { | |
| frame = frames[0]; | |
| frame_line = lines[0]; | |
| } | |
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
benchRake task invokesbench/benchmark.rb, but there is nobench/directory in the repo (sorake benchwill fail immediately). Either add the benchmark script/directory in this PR or adjust/remove the task to point at an existing benchmark entrypoint.