Request for Custom Carrier Thread Group Support in Project Loom
Alan Bateman
alan.bateman at oracle.com
Sun Aug 24 17:46:51 UTC 2025
On 20/07/2025 11:29, Victor Madu wrote:
> :
>
> Are there any plans to support this level of carrier group
> configurability in future versions of the JDK or Project Loom? Even an
> opt-in or expert-mode API would go a long way in allowing more
> fine-tuned control for advanced users without impacting the simplicity
> that Loom provides by default.
>
>
There isn't a plan to expose anything at this time. It's a topic where
caution is required because custom schedulers is essentially executing
arbitrary code at sensitive times, e.g. exiting a monitor may require
scheduling a successor that is a virtual thread. Interaction with the
scheduler may be in the context of a carrier or virtual thread. It's way
too easy to self deadlock when attempting to coordinate between mounted
virtual threads and carriers using any form of synchronization.
That said, there are some work loads that aren't suited to work
stealing schedulers and there may be a case for using a different
scheduler for these cases. Whether that is built-in or provided by some
framework is an open question. There is an experimental/prototype
changes in the loom repo and a VirtualThreadScheduler interface. The
prototype allow you to set your own implementation via a system property
on the command. This includes interposing on the built-in scheduler.
There is also a prototype API for setting the scheduler when creating a
virtual thread. There is brief summary in a document [1] in the repo. If
you do try it out then it would be very helpful if you could come back
to report your experiences as that will help this project decide if
there is a case for providing something.
-Alan
[1]
https://github.com/openjdk/loom/blob/fibers/loom-docs/CustomSchedulers.md
More information about the loom-dev
mailing list