Closed ujibang closed 7 months ago
All blocking tasks are now dispatched to the VirtualThreadPerTaskExecutor, ensuring efficient task execution and concurrent programming.
However, a known limitation is with the Truffle JS engine, which currently lacks support for virtual threads. To mitigate this, the truffle-runtime has been excluded from the restheart.jar.
Overview
Java 21 introduces Virtual Threads, a feature detailed in JEP 444. These lightweight threads significantly boost performance and simplify concurrent programming.
RESTHeart 8 harnesses
Executors.newVirtualThreadPerTaskExecutor()
to manage requests handled by services marked as blocking (withRegisterPlugin(blocking = true)
by default), efficiently processing blocking services.Furthermore, RESTHeart 8 configures Undertow to use its
ThreadAwareByteBufferPool
for optimized resource allocation:undertow.DefaultByteBufferPool
to efficiently pool resources.NotPoolingByteBufferPool
, which avoids pooling to enhance performance given the distinct characteristics of virtual threads.Rationale
Configuration
The following options manage virtual threads: