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.
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 becauseof 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 storethe 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.