-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: Internal, Performance
-
None
Virtual threads were added in Java SE 21 (see https://openjdk.org/jeps/444). The driver can take advantage of them, even though its minimum Java version is still 8, with a little indirection that detects whether virtual threads are supported (using reflection, most likely), and creating virtual threads instead of platform threads when they are available.
Virtual threads seem ideal for all threads currently created by the driver itself, including those in:
- DefaultServerMonitor
- DefaultConnectionPool
- DefaultDnsSrvRecordMonitor
See this comment for the design thoughts. Some of the thoughts were implemented in AsyncClientExecutor, CommonExecutor added in JAVA-6240.
- Ideally, these two classes should manage all execution resources, so that we would not have many places where we create new executors and threads.
- At the very least for any new functionality, we should consider reusing the threads already managed by AsyncClientExecutor, CommonExecutor, instead of creating more threads. If not creating more threads is impossible/impractical, we at least should manage those new threads by either AsyncClientExecutor or CommonExecutor.