kotlinx.coroutines icon indicating copy to clipboard operation
kotlinx.coroutines copied to clipboard

Make thread names of CoroutineScheduler more distinguishable

Open qwwdfsad opened this issue 1 year ago • 0 comments
trafficstars

Currently, names of all threads that belong to CoroutineScheduler (Dispatchers.Default, Dispatchers.IO and Dispatchers.IO.limitedParallelism(...) are named DefaultDispatcher-worker-* which might be quite confusing to look at in thread dumps (i.e. it's possible to have dozens of such threads on 8 core machine). Example of such confusion: https://stackoverflow.com/questions/78502056/why-thread-name-is-defaultdispatcher-worker-even-though-i-specify-function-to-ru

While we cannot leverage Thread.setName because of its performance impact, we still can sweeten the pill:

  • Name the thread somehow more generic (for example: CoroutineScheduler-worker-, something like shared-pool-worker-, coroutine-pool-worker- etc.)
  • Add an artificial stackframe that indicates that the thread was spawned and/or is parked as part of the "IO" pool if it's possible implementation-wise

qwwdfsad avatar Nov 05 '24 19:11 qwwdfsad