Hi.
Could I have done something wrong to exhibit this non-obvious behavior?
No, this is rather a framework issue. What I can recommend is to avoid CIO engine in Ktor for a while, it is in experimental status and its performance in an idle state is yet to be tuned. And as you can observe, Ktor CIO uses two instances of such dispatcher ad that does not help as well.
About why DefaultDispatcher
consumes a lot of CPU: it was optimized for either heavy-load (when CPU is utilized in 80-100%) or very low load (close to zero with occasional IO): it adaptively spins when it is out of work and park only after some delay (parking and unparking is expensive), thus burning CPU for a while. It is much performant in a high load cases, but pays for it with increased CPU consumption in idle state.
There definitely could be some improvements and knobs in the dispatcher. Could you please report some sample project where you experience an unexpected CPU consumption due to default dispatcher to Issues · Kotlin/kotlinx.coroutines · GitHub?