Fix worker thread name index#3591
Conversation
I have some recollection that the |
|
Hm, that's interesting. I'm not sure (any more) what was the original intention. I thought, that working workers should have the WSTP index in their names, because when a cached thread becomes a worker, it is carefully set to that: https://github.com/typelevel/cats-effect/blob/series/3.x/core/jvm/src/main/scala/cats/effect/unsafe/WorkerThread.scala#L845. But apparently this is not true for new (replacement) workers. So now I made it so (my 2 new commits). It is completely possible, that I imagined this whole "name should have the WSTP index" thing. But seeing 2 threads with the same name in visualvm is pretty confusing (it did happen, that's how I found this). So this PR should fix that... |
|
It just occurred to me, that it's completely possible (even likely), that the call in My approach (currently in this PR) has the advantage of having the WSTP workers name end with their WSTP index. The (probably) originally intended approach has the advantage of threads having a stable postfix in their names, and it's just the prefix which changes when they move in/out of the WSTP. |
Yeah, fwiw I like the sound of this. |
|
WSTP index did not need to be the same as the name index, but if it helps debugging, go for it. |
djspiewak
left a comment
There was a problem hiding this comment.
Definitely a fan of anything that improves introspectibility.
Strangely, the initial name of the
WorkerThreadsis one higher than their (zero-based) index in the WSTP (i.e.,io-compute-1,io-compute-2, ... instead ofio-compute-0,io-compute-1, ...). After a worker is converted to a blocker, and then returns to the WSTP, its name will have the correct index (i.e., zero-based). Confusingly, this can cause two worker threads to have the same name. E.g., originallyio-compute-2(with index1) becomesio-compute-1, but there could be anotherio-compute-1(with index0).This PR fixes this inconsistency.