Jilles van Gurp
10/27/2023, 12:56 PMe5l
10/27/2023, 1:07 PMthreadsCount
is a good solution.
Having multiple dispatchers with different thread pools could lead to switching threads (possibly multiple time) for a single coroutine (code path). It can introduce noticeable delays in the low utilised workflows and consume cpu.
That’s why we try to stick with the Dispatchers
from `kotlinx.coroutines`: switching between Default
and IO
dispatchers shouldn’t have this issue, but custom thread pool dispatchers can.
If you have any ideas on how we can improve this, please let me knowJilles van Gurp
10/27/2023, 3:30 PMOliver.O
11/08/2023, 5:36 PM<http://Dispatchers.IO|Dispatchers.IO>
is probably not a good idea as it can lead to thread starvation. Neither is using a separate thread pool due to reasons mentioned. Always use <http://Dispatchers.IO|Dispatchers.IO>.limitedParallelism(...)
instead. For details, see https://github.com/JetBrains/skiko/issues/823