Hello everyone! Interested in how to use Project L...
# feed
h
Hello everyone! Interested in how to use Project Loom to improve Coroutines' performance? See the article written by Jan Vladimir Mostert ๐Ÿ‘‡ https://kt.academy/article/dispatcher-loom
๐Ÿ‘๐Ÿป 1
๐Ÿ‘ 10
think smart 2
d
Wow, interesting! Are there any drawbacks to this approach such as IntelliJ debugging issues etc? Does JetBrains plan to migrate coroutines to utilize project loom once that gets released?
j
The debugger might look a little rougher than what you're used to (virtual threads and coroutine threads mixed in the same stacktrace), but it works fine. There was a time when coroutines looked a little rough too, but it got prettified eventually. Would be nice to have a Dispatchers.LOOM directly in the Coroutines library ๐Ÿ˜
c
JetBrains employees have said multiple times that they are waiting for the full release of Loom before making a decision. Since Loom is Java-only, it's unlikely to cause any API difference, so if they do decide to use it it's unlikely to change much for us.
@janvladimirmostert how did you get the "coroutine stack trace" feature in the debugger working? I never managed to ๐Ÿ˜•
m
More precisely, LOOM will be, say, Java 2x-only, meaning coroutines will need to be implemented as they are for earlier JREs and Android.
j
it would make sense if Dispatchers.IO automatically defaulted to Virtual Threads if you compiled with JDK20+ and then defaulted to the Thread Pool for JDK19 and lower.
๐Ÿ‘ 1
@CLOVIS, my coroutine stacktrace just works in IntelliJ Ultimate, didn't tinker with anything to get it working.
m
@Halina The counterpart for Thread.sleep in kotlinx.coroutines is
delay()
function and using it would likely make the comparison much more on pair. And for actual blocking code I would not expect much difference either, maybe so if Loom finally specializes java IO operations.
h
@mcpiroman let's see what the author @janvladimirmostert thinks of that ๐Ÿ™‚
d
@mcpiroman since Kotlin allows you to specify the JDK target in the Gradle build, I would assume that it could use loom threads when targeting JDK20+