diff options
author | Jean Boussier <[email protected]> | 2023-11-09 13:56:29 +0100 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2023-11-13 08:45:20 +0100 |
commit | 9ca41e999159096cb0872b4babbb94bf5d1af4ce (patch) | |
tree | 997d7847124e8ddcadc75413b7eb6b0a587e1772 /thread.c | |
parent | 4376a17552670021a9175bb487be8eb16a2a97e9 (diff) |
GVL Instrumentation: pass thread->self as part of event data
Context: https://github.com/ivoanjo/gvl-tracing/pull/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.
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -5409,7 +5409,7 @@ Init_Thread(void) // thread_sched_to_running(sched, th); #ifdef RB_INTERNAL_THREAD_HOOK - RB_INTERNAL_THREAD_HOOK(RUBY_INTERNAL_THREAD_EVENT_RESUMED); + RB_INTERNAL_THREAD_HOOK(RUBY_INTERNAL_THREAD_EVENT_RESUMED, th); #endif th->pending_interrupt_queue = rb_ary_hidden_new(0); |