Closed byroot closed 1 year ago
I like that! I took a very simple stab at it in 944d4d3aa3c5d42225641340d914456b06762a25 but definitely think it'd be interesting to add more.
I guess the main constraint here is being careful that we only read Thread#name
or Thread#inspect
when we're holding the GVL (or its modern equivalent) as from what I could tell, not all the callbacks get triggered when that happens (...right?).
But definitely suggestions are welcome!
Good idea
Also with the native extension (https://github.com/ivoanjo/gvl-tracing/blob/master/ext/gvl_tracing_native_extension/gvl_tracing.c#L90). How much can we reuse from Thread#to_s
code?
I guess the main constraint here is being careful that we only read
Thread#name
orThread#inspect
when we're holding the GVL
Absolutely. Ideally we'd just dump the native thread id in the file, and only later do the mapping / rewrite. Some epehmeral threads may have been GCed, but I guess that's acceptable (even more so because ephemeral threads are recycled, so they won't show up properly anyway).
Fixed in #12
Ruby 3.2 added
Thread#native_thread_id
When available I think we could use that to find the Ruby thread and provide more information about the thread.
If
Thread#name
returns something we could use that, otherwise we can probably report the location of its first frame likeThread#inspect
.cc @benoittgt