# coroutines

Marty Pitt

08/06/2021, 10:22 AM
Hi all. We've recently moved a single-threaded blocking process across to coroutines and Flow<>. We're trying to profile performance, and understand the "cost" of coroutines, to see if there's ways we can optimize. (We're not satisified with our performance currently, and looking for areas to tune). Are there any tools that can help with visibility of this, and understanding what's going on?


08/06/2021, 11:11 AM
Logging can help you figure out what's happening.

Alex Prince

08/06/2021, 1:08 PM
My understanding ( and experience) is that coroutines are pretty light, but, the CPU profiler in Android Studio was quite helpful for me, just, when you're looking at thread names, bear in mind that IO and Default actually share a threadpool under the hood, so "default" tagged threads may be used by the IO dispatcher if they're free
The other thing to watch that we found if you're moving from blocking calls is, you CAN exhaust your dispatcher thread pools pretty easy if your coroutines are actually blocking instead of suspending. ( for us it was mostly old volley network calls that were still blocking on the future instead of suspending)

Marty Pitt

08/09/2021, 12:45 PM
Thanks both for your assistance / feedback. Shame that tooling isn't better here. We've been burnt previously with a move to Reactor, which can be surprisingly non-performant when used incorrectly, so had hoped we'd be able to see something that helps visualise inactive / waiting co routines.


08/17/2021, 1:39 PM