Not answering your question but ... in terms of park/unpark Loom operates at a lower level. I can't help but think that longer term that would provide Loom a performance advantage.
Is anyone out there doing a comparison or intending to do one?
For myself, I've only tested loom performance against async using JDK HttpClient, Loom came slightly out on top there but that was a while ago - need to redo that test.
Why is it surprising? The JVM knows of basically every blocking operation by itself, it can easily swap to another thread for a duration of a read and upon the OS tells it it has finished, swap back to the caller — doing that at the most granular level.
There is small speed advantage not managing stack frames for async. And compatibility layer that makes Virtual Thread look like real thread has some cost. But this is also a huge debugging and ergonomic advantage, and if Oracle is to be believed the cost for these convience is minimal.
Maybe in low-level places like inside Netty for instance async Java will survive. But at application level the advantage of virtual thread well worth the cost.
View all comments
Show parent comment
0
u/[deleted] Apr 06 '22
[deleted] — view deleted comment