Skip to content

Make thread names of CoroutineScheduler more distinguishable #4267

Open
@qwwdfsad

Description

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions