-
Notifications
You must be signed in to change notification settings - Fork 381
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
[PROF-10128] Refactor and speed up profiler stack sampling #3837
Merged
ivoanjo
merged 17 commits into
master
from
ivoanjo/prof-10128-stack-sampling-improvements
Aug 13, 2024
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d5062c5
Minor: Make argument name in header match actual function
ivoanjo 9c61d60
Add helper function to clear per_thread_context
ivoanjo 3d4b7fc
Remove sampling_buffer argument from record_placeholder_stack
ivoanjo 5fd0460
Extract checking max_frames into a separate function
ivoanjo dc59c0a
Make sampling_buffers per-thread
ivoanjo 99d5915
Avoid allocating locations for every sampling_buffer/thread
ivoanjo 05e552c
Use smaller type for max_frames
ivoanjo 71839e0
Avoid repeating call to rb_profile_frame_path for cframes
ivoanjo ca04090
Avoid retrieving rb_callable_method_entry_t in ddtrace_rb_profile_frames
ivoanjo 9039572
Introduce `frame_info` to contain sampled stack frame information
ivoanjo 47044b0
Introduce caching for sampled stacks
ivoanjo 360aba2
Use cheaper `RSTRING_PTR` when converting string to char slice
ivoanjo be447a9
Fix build/running with DDTRACE_DEBUG
ivoanjo c09aaae
Directly use VM iseq query functions instead of going through rb_prof…
ivoanjo 2fc03d5
Add workaround for spec that started flaking
ivoanjo e6c9122
Clarify why code is being left commented out
ivoanjo 607d5d5
Pick up upstream fix for `start` parameter
ivoanjo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,13 +22,16 @@ typedef struct frame_info { | |
union { | ||
struct { | ||
VALUE iseq; | ||
void *caching_pc; // For caching only | ||
int line; | ||
} ruby_frame; | ||
struct { | ||
VALUE caching_cme; // For caching only | ||
ID method_id; | ||
} native_frame; | ||
} as; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Such fluent! Much API! Wow! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something something great artists copy. |
||
bool is_ruby_frame : 1; | ||
bool same_frame : 1; | ||
} frame_info; | ||
|
||
rb_nativethread_id_t pthread_id_for(VALUE thread); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
So in the past, the same cfp would "eat" all the
start
whereas now it'll skip just one? Not sure if this was ever something we relied on but just highlighting this slight change in behaviour.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.
This is a really great catch!
I completely glossed over it because a) we don't use
start
and b) I remembered some discussion somewhere mentioning it was actually broken.It's actually fixed nowadays https://bugs.ruby-lang.org/issues/14607 // ruby/ruby#8280 . I had spotted that upstream had moved the
cfp = ...
to the for header as well, but I hadn't spotted it was to fixstart
.I did spot that upstream also added the start skip logic to the
if (cme && cme->def->type == VM_METHOD_TYPE_CFUNC)
branch below. I'll push a commit to add this one as well, so we keep closer to upstream in case we ever want to usestart
.