-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely a fan of anything that improves introspectibility.
Strangely, the initial name of the
WorkerThreads
is 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.