-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Explain that enabling virtual threads disables traditional thread pools #41937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm not sure I understand what's being suggested here. Is this about setting Maybe you're suggesting to somehow configure a different In all cases, using Right now the property is documented like so: Looking at the StackOverflow question, it seems that the root problem is about thread pinning, which can happen in any library using virtual threads (not just Tomcat) and impact the entire application. I believe this issue should not be fixed by sizing the platform thread pool but rather using the tools provided by the JVM to find the problem. |
This seems to be the most logical to me, as it would result in the same amount of platform threads regardless of whether Spring Boot is run with or without virtual threads. Another option is to split
You mean explicitly specifying that the option denotes amount of platform threads? |
With As for splitting
No, I meant making the description a bit more explicit by saying that those worker threads belong to a thread pool, which is irrelevant once virtual threads are enabled. I'm not sure how to make this more obvious from the property description. Maybe we can expand this part of our reference documentation to say that where virtual threads are supported, traditional thread pools (and their properties) will be skipped entirely. |
Sounds reasonable.
Description of |
When virtual threads are enabled, frameworks or libraries that traditionally used thread pools might either disable these pools or adjust their usage patterns. For example, an executor service might be designed to use a fixed number of platform threads, but with virtual threads, this concept becomes unnecessary. The JVM might internally disable or bypass the logic that manages traditional thread pools, because it’s now more efficient to directly manage virtual threads. |
I've added something to the documentation and also to the property descriptions. |
While investigating this issue https://stackoverflow.com/questions/78790376/spring-boot-application-gets-stuck-when-virtual-threads-are-used-on-java-21 I've found out, that the property
works only for platform threads and doesn't affect amount of carrier threads in
ForkJoinPool
whenthe only way to change their amount is to use
-Djdk.virtualThreadScheduler.parallelism=n
which seems to be wrong in this case as it would affect all the JVM, not one particularForkJoinPool
. See https://stackoverflow.com/questions/78815247/can-i-configure-parallelism-of-forkjoinpool-created-for-tomcat-in-spring-boot-ap/78815410The text was updated successfully, but these errors were encountered: