janvladimirmostert
01/09/2023, 9:26 AMCLOVIS
01/09/2023, 2:38 PMjanvladimirmostert
01/09/2023, 5:36 PMCLOVIS
01/09/2023, 5:46 PMdelay
. But even then, “it makes doing nothing faster” is not a strong argument.mbonnin
01/10/2023, 3:31 PMThread.delay
that benefits from Loom?mbonnin
01/10/2023, 3:32 PMselect
needs to schedule a new thread, right?CLOVIS
01/10/2023, 3:33 PMCLOVIS
01/10/2023, 3:33 PMCLOVIS
01/10/2023, 3:34 PMmbonnin
01/10/2023, 3:34 PMsleep()
or select()
IIRC from my low level C daysmbonnin
01/10/2023, 3:35 PMinputStream
calls select()
my understanding is it's going to schedule a new (real, not virtual) thread.mbonnin
01/10/2023, 3:35 PMCLOVIS
01/10/2023, 3:36 PMCLOVIS
01/10/2023, 3:36 PMmbonnin
01/10/2023, 3:37 PMCLOVIS
01/10/2023, 3:38 PMCLOVIS
01/10/2023, 3:38 PMCLOVIS
01/10/2023, 3:38 PMmbonnin
01/10/2023, 3:44 PMCLOVIS
01/10/2023, 3:46 PMmbonnin
01/10/2023, 3:47 PMThreadLocal
..CLOVIS
01/10/2023, 3:50 PMmbonnin
01/10/2023, 3:52 PMThreadLocal
used a lot though?mbonnin
01/10/2023, 3:52 PMmbonnin
01/10/2023, 3:52 PMCLOVIS
01/10/2023, 3:53 PMCLOVIS
01/10/2023, 3:53 PMCLOVIS
01/10/2023, 3:54 PMmbonnin
01/10/2023, 3:54 PMCLOVIS
01/10/2023, 3:54 PMCLOVIS
01/10/2023, 3:55 PMCLOVIS
01/10/2023, 3:55 PMmbonnin
01/10/2023, 3:56 PMmbonnin
01/10/2023, 3:56 PMmbonnin
01/10/2023, 3:56 PMmbonnin
01/10/2023, 4:50 PMmbonnin
01/10/2023, 4:51 PMCLOVIS
01/10/2023, 4:53 PMmbonnin
01/10/2023, 4:53 PMCLOVIS
01/10/2023, 4:53 PMmbonnin
01/10/2023, 4:56 PMCLOVIS
01/10/2023, 4:58 PMCLOVIS
01/10/2023, 4:59 PMmbonnin
01/10/2023, 5:00 PMCLOVIS
01/10/2023, 5:01 PMkevin.cianfarini
01/10/2023, 8:54 PMI mean the kernel doesn’t have that many IO primitives, it’s mostly eitherThis isn’t true. On Linux you haveorsleep()
IIRC from my low level C daysselect()
select
, poll
, epoll
, and io_uring
. I’m actually working on binding io_uring to K/N.
On bsd you have kqueue
and select
.
on mingw you have ioctl
which is iirc similar to kqueue.kevin.cianfarini
01/10/2023, 8:55 PMkevin.cianfarini
01/10/2023, 8:55 PMkevin.cianfarini
01/10/2023, 8:56 PMmbonnin
01/10/2023, 8:56 PMselect
and poll
in the same categorymbonnin
01/10/2023, 8:56 PMpoll
being an improvement on select
IIRC?kevin.cianfarini
01/10/2023, 8:56 PMkevin.cianfarini
01/10/2023, 8:57 PMmbonnin
01/10/2023, 8:57 PMkevin.cianfarini
01/10/2023, 8:57 PMkevin.cianfarini
01/10/2023, 8:57 PMkevin.cianfarini
01/10/2023, 8:58 PMmbonnin
01/10/2023, 9:00 PMkevin.cianfarini
01/10/2023, 9:00 PMkevin.cianfarini
01/10/2023, 9:01 PMmbonnin
01/10/2023, 9:01 PMkevin.cianfarini
01/10/2023, 9:01 PMkevin.cianfarini
01/10/2023, 9:01 PMkevin.cianfarini
01/10/2023, 9:02 PMmbonnin
01/10/2023, 9:02 PMkevin.cianfarini
01/10/2023, 9:02 PMkevin.cianfarini
01/10/2023, 9:03 PMkevin.cianfarini
01/10/2023, 9:03 PMkevin.cianfarini
01/10/2023, 9:03 PMCLOVIS
01/10/2023, 9:04 PM<http://Dispatchers.IO|Dispatchers.IO>
to end up Loom at some point in the future, so we would get all of this for free for current coroutine-based programs, without any behavior difference for other platformskevin.cianfarini
01/10/2023, 9:05 PMkevin.cianfarini
01/10/2023, 9:05 PMkevin.cianfarini
01/10/2023, 9:07 PMDispatchers.LOOM
will be the best interop story between coroutines and loom.kevin.cianfarini
01/10/2023, 9:07 PMCLOVIS
01/10/2023, 9:09 PMkevin.cianfarini
01/10/2023, 9:14 PMSo the JVM is limited in what it can do. Whenever someI don’t think that’s necessary true. A general pattern I’ve seen used is to have one “nonblocking main thread” and one “worker thread”. The worker thread is the entity responsible for notifying consumers of IO completion events and dispatching them. The main thread will request some IO thing to be performed and go do other non-blocking things. That’s how the non-blocking IO impl works on top ofcallsinputStream
my understanding is it’s going to schedule a new (real, not virtual) thread.select()
select(2)
in the ktor-network package and that’s how my io_uring impl works.
If you want a program to be truly single threaded and perform io_work, you have to transform the entire program into an event loop. This essentially condenses the work of a dispatcher type thing and the business logic of your program into a single thing.
the io_uring examples do this where the main function is pretty much just a wrapper around a while (!done)
loop.kevin.cianfarini
01/10/2023, 9:15 PMmbonnin
01/10/2023, 9:30 PM> So the JVM is limited in what it can do. Whenever somecallsinputStream
my understanding is it’s going to schedule a new (real, not virtual) thread.select()
I don’t think that’s necessary trueYup, that was my wrong initial assumption. Loom can actually
select()
/ poll()
from multiple inputStreams
in different virtual thread and schedule only one carrier thread. Cool stuff!mbonnin
01/13/2023, 10:51 AM