Coroutines Dispatchers.IO
context is limited to 64 threads. That's not enough to reliably interface with blocking code in highly-concurrent system.
Documentation states that:
Additional threads in this pool are created and are shutdown on demand. The number of threads used by this dispatcher is limited by the value of “kotlinx.coroutines.io.parallelism” (IO_PARALLELISM_PROPERTY_NAME) system property. It defaults to the limit of 64 threads or the number of cores (whichever is larger).
I want to change kotlinx.coroutines.io.parallelism
system property to something else. However, if I just do this:
adb shell "setprop kotlinx.coroutines.io.parallelism 1000"
then I get the following result:
setprop: failed to set property 'kotlinx.coroutines.io.parallelism' to '1000'
Furthermore, if I want to ship my app, then I'll need to change this property on users' devices as well, right? Otherwise the app won't work. However, even assuming that it's possible, as far as I understand, all apps that change this property will override the setting for one another. This doesn't sound like a reliable mode of operation.
So, I have three questions in this context:
- Is the property implied in documentation is indeed the "system property" that I tried to change?
- How to change this property on non-rooted device for all users of my app?
- Is there better alternative?
P.S. I know that if I'd only use coroutines, without blocking code, this wouldn't be a problem (probably). But let's just assume that I need to use blocking calls (e.g. legacy Java code).