Project Loom and io_uring integration

Ilya Korennoy korennoy.ilya at gmail.com
Fri Sep 23 12:10:03 UTC 2022


Hello!

I am studying Project Loom and thinking about its integration with
io_uring, and I wanted to clarify a couple of questions.

I've studied the implementation of Socket in Java 19 and the integration of
epoll and Loom. The idea is clear, Loom thread tries to read from the
socket if it fails it goes to sleep, when epoll returns an event Loom
thread wakes up and tries to read again. The epoll readiness model
integrates well with Loom.

Io_uring has a different model: completion. The interface itself does the
I/O, then returns the result. I understand how to integrate callback-based
systems like CompletableFuture or Kotlin Coroutines with this model, but I
have absolutely no idea how to make integration with Loom.

I have the following questions:

In the current socket implementation, when we need to stop a thread (the
socket is not ready) it is saved in Map, where the key is the fd of that
socket. When epoll returns the result we take the thread out of Map and
keep it running.
In case of io_uring we can save Callback (CompletableFuture or Kotlin
Continuation), but what would you save in case of Loom? Thread is not
suitable since we need to send the result that io_uring returned.

I assume one way or another we can make an implementation that will return
Future. In case of Loom threads, Future.get, which blocks the calling
thread will just stop the loom thread, so it's kind of possible to do it
without fear of blocking the system thread. But, this is only if we're
really on a Loom thread. Take Netty, for example. Netty doesn't use Loom
and is unlikely to do so. Request execution will be on one of the Netty
Reactor threads, in case of Kotlin Coroutines we can call suspend function
on this thread and it won't be blocked (in case of blocking operations we
can use IO Dispatcher, in case of io_uring it is asynchronous), but with
Loom we can't call future.get, because in this case netty thread will be
blocked. How should the integration work properly in this situation?

Regards,
Ilya Korennoy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20220923/133ba161/attachment.htm>


More information about the loom-dev mailing list