https://kotlinlang.org logo
#coroutines
Title
# coroutines
j

Joe

03/10/2020, 6:26 PM
Noticing a performance degradation in a test using coroutines version 1.3.4 vs/ 1.3.3. The test uses Dispatchers.Default and does something like the following: • Launch a coroutine that collects a
channel.consumeAsFlow()
• Send a message to the channel that results in another coroutine that sends another message to the channel that results in decrementing a
CountDownLatch
• In the main thread, await the
CountDownLatch
With 1.3.3, the await took ~180ms. With 1.3.4 its taking ~1.4 seconds. Not sure how this affects the production code yet, but is there a change in 1.3.4 that would explain this?
🎬 1
🍿 2
👀 3
o

octylFractal

03/10/2020, 6:29 PM
there was a change to improve the efficiency of the default dispatcher, but perhaps it regressed -- it would be much easier to track down an exact cause if you provide a minimal & complete example
j

Joe

03/10/2020, 6:32 PM
complete example is here https://github.com/trib3/leakycauldron/blob/master/graphql/src/test/kotlin/com/trib3/graphql/websocket/GraphQLWebSocketTest.kt#L499-L561 specifically the
data.await()
on line 544 is what's regressed in timing. but it's not exactly minimal. I'll see if I can get something smaller to reproduce.
ok more minimal example here: https://gist.github.com/josephlbarnett/1ebd20d5c3cb3684238a6d4d6f81574c -- looks like its another .asPublisher().asFlow() related issue, possibly caused by the fix for another one (https://github.com/Kotlin/kotlinx.coroutines/issues/1825)
5 Views