graal icon indicating copy to clipboard operation
graal copied to clipboard

[GR-71790][Truffle] Option to isolate Truffle on platform threads to avoid global virtual thread downgrade in native image

Open Rhython opened this issue 3 weeks ago • 2 comments

Is your feature request related to a problem? Please describe.

When using GraalVM 25 native image, any inclusion of the Truffle library causes all virtual threads to degrade to platform threads, even if only a subset of the application uses Truffle. This results in performance penalties for business logic that solely relies on virtual threads and does not require Truffle functionality.

Describe the solution you'd like.

Even though Truffle currently does not support virtual threads, I would like to have an option which restricts Truffle operations to only run on platform threads. Ideally, if Truffle is invoked from a virtual thread, the operation could immediately throw an error, or got undefined behavior. This would ensure that parts of the application which never use Truffle (and don't depend on its usage) can still fully benefit from the performance offered by virtual threads, avoiding a global downgrade to platform threads as soon as Truffle is present.

Describe who do you think will benefit the most.

Developers using GraalVM native image to build high-performance Java applications leveraging virtual threads, but who include Truffle (directly or via dependency) for separate features.

Describe alternatives you've considered.

I have considered separating services or refactoring the application to avoid dependencies on Truffle entirely where virtual threads are needed. However, this is impractical in larger projects with shared dependencies.

Additional context.

GraalVM 25 Native Image, Truffle, virtual threads.

Express whether you'd like to help contributing this feature

I don't have enough experience to work on this project

Rhython avatar Dec 02 '25 03:12 Rhython

Thank you for sharing this request, we'll take a look into this feature's feasibility as soon as possible.

oubidar-Abderrahim avatar Dec 02 '25 10:12 oubidar-Abderrahim

I think this is a duplicate of #7520?

wirthi avatar Dec 09 '25 10:12 wirthi