GVL Instrumentation: pass thread->self as part of event data #8885
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.
Replaces: #6189
Context: ivoanjo/gvl-tracing#4
Some hooks may want to collect data on a per thread basis. Right now the only way to identify the concerned thread is to use
rb_nativethread_self()
or similar, but even then because of the thread cache or MaNy, two distinct Ruby threads may report the same native thread id.By passing
thread->self
, hooks can use it as a key to store the metadata.NB: Most hooks are executed outside the GVL, so such data collection need to use a thread-safe data-structure, and shouldn't use the reference in other ways from inside the hook.
They must also either pin that value or handle compaction.
cc @ko1 @tenderlove @ivoanjo