Virtual threads vs JMM + public API for replacing scheduler

Alan Bateman Alan.Bateman at oracle.com
Tue Nov 22 12:15:05 UTC 2022


On 22/11/2022 09:37, Krzysztof Ślusarski wrote:
> Hi, currently in performance world you can see a lot of investment in
> thread-per-core architecture. I tried to use loom virtual threads to
> create a POC with such a design, and I see two missing parts:
> - I cannot find any information about how virtual threads are
> connected with Java Memory Model. If I have multiple virtual threads
> that are running on the same carrier thread, can I treat it as
> single-threaded execution in terms of JMM?
> - There is no public API for switching the scheduler (I believe there
> was one in the past), can we ask for bringing it back?
>
> With those two it would be trivial to write TPC application in java.
> You create multiple single threaded executors, use thread affinity to
> pin the threads to specific cores and then use virtual threads on the
> top of that.
We want to eventually allow custom schedulers but it requires more 
exploration. There are issues to work through around the ownership of 
monitors and also around blocking operations that temporarily pin a 
virtual thread to its carrier.

Custom schedulers that are using processor affinity may be able to 
document expectations on memory/ordering when a set a virtual threads is 
scheduled to a specific carrier but that would lead to code that may not 
run correctly elsewhere.

-Alan



More information about the loom-dev mailing list