I’m seeing some pretty disappointing CPU usage fro...
# coroutines
k
I’m seeing some pretty disappointing CPU usage from a low throughput coroutines workload (sending ~40-50 network requests per second) that is all non-blocking I/O, barely any CPU work. Using the async profiler shows the DefaultDispatcher threads are spending the majority of their time in the coroutines scheduler (mostly in
Worker.doPark
or
WorkQueue.trySteal
. Is this… expected?
l
I don't understand your question, you say you are disappointment in CPU usage and you say you you have tasks that do barely any CPU work. Seems like a contradiction to me. If the tasks are IO bound then I would expect all the threads to be parked doing nothing.
k
My point is that the coroutine scheduler itself is using much more CPU than I would expect
m
When your code is mainly waiting for IO, then the percentage of time spent in the scheduler will go up because nothing else are running.
k
@elizarov @Vsevolod Tolstopyatov [JB] is it possible this branch will improve things? https://github.com/Kotlin/kotlinx.coroutines/tree/scheduler-changes
v
yes, that's its point :)
k
👍
i’d test instead of ask a stupid question but I can’t seem to build it right now because I don’t have Xcode installed
this jprofiler call tree seems crazy to me. 12 million invocations of
findTaskWithCpuPermit
to only 20,000 actual calls into suspended code (
DispatchedTask.run
)
v
(sending from my phone, so can't give more detailed instructions) you can comment out all native targets from https://github.com/Kotlin/kotlinx.coroutines/blob/master/gradle/compile-native-multiplatform.gradle
k
(image not uploading)
thanks for the link
message has been deleted
@Vsevolod Tolstopyatov [JB] that branch makes a significant difference in CPU usages. Nice work 👍