|
|
|
|
|
by throwawayisize
1333 days ago
|
|
FTA, it's pretty clear. Typically, a virtual thread will unmount when it blocks on I/O or some other blocking operation in the JDK,
such as BlockingQueue.take(). When the blocking operation is ready to complete (e.g., bytes have been
received on a socket), it submits the virtual thread back to the scheduler, which will mount the virtual
thread on a carrier to resume execution.
The mounting and unmounting of virtual threads happens frequently and transparently, and without blocking any
OS threads. For example, the server application shown earlier included the following line of code, which
contains calls to blocking operations: response.send(future1.get() + future2.get());
These operations will cause the virtual thread to mount and unmount multiple times, typically once for each call to get() and possibly
multiple times in the course of performing I/O in send(...).
> Non-blocking IO is about interrupts at the hardware levelThis isn't relevant. We only care from the perspective of userspace. |
|
What is unclear is whether or not Loom will increase performance of the server I/O (not the application logic code) that is already working well with non-blocking Selectors. I doubt it. But if someone has a Loom implementation of a plain HTTP server (nothing complex or JEE), I'd be up for some benchmarking exercises.
Overall though, I don't think Loom negates the usefulness of java-http. We built a super simple API, with no dependencies, that works with Java 17 and above, supports TLS natively, and is insanely fast.
Am I missing something?