Hi all. We've recently moved a single-threaded bl...
# coroutines
m
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?
l
Logging can help you figure out what's happening.
a
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)
m
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.
r
BlockHound?