-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Kotlin Coroutine suspend function Integration uses single thread dispatcher #41288
Comments
/cc @geoand (kotlin) |
Can someone point me to the source code of the coroutine dispatcher implementation, then I can take a look and try to debug the problem. |
I found this dispatcher implementation which is used by the resteasy reactive client. Lines 34 to 51 in 32d0c2d
There is also a similar implementation in the vertx extension https://github.com/quarkusio/quarkus/blob/ea2c6a4090d1eccb4b39250198601f7da9454833/extensions/vertx/kotlin/runtime/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/VertxDispatcher.kt Both implementations do not use the existing vertx Dispatcher and implement a very basic execution of coroutine on the vertx event loop. |
I am also interested in the outcome of the analysis of this issue. |
Thanks for opening this! Just so I understand this, you are saying that when are manually handling the launch of coroutines, the dispatcher is single threader? Also, some comments on things mentioned above:
The code you have linked to is for the Quarkus REST server part, not the client.
Which one are you refering to as |
The |
Oh, I was not aware of that one at all...
|
@geoand why can the Dispatcher from vertx-lang-kotlin-coroutines not be used in quarkus. If it can not reused, what changes are needed in quarkus to port the Dispatcher from vertx-lang-kotlin-coroutines. |
See the code in RESTEasy Reactive that uses its own dispatcher |
Describe the bug
When working with kotlin coroutines and suspend functions in quarkus, the code is executed sequentially by a single thread by default. One has to explicitly change the kotlin coroutine dispatcher to get the expected behavior of the
Dispatchers.Default
which uses a Thread pool.Expected behavior
By default when using suspend function with quarkus the
Dispatchers.Default
orVertx.vertx().dispatcher()
should be used as the dispatchers. Or it should be possible to configure the used Dispatcher.Actual behavior
Some single threaded Dispatcher is used (maybe
runBlocking
is used) to run the suspend functions.How to Reproduce?
Add the following code to an RestEasy Resource and call the endpoint
Output: total time 10 seconds
Output: total time 1 second
Output: total time 1 second
Output of
uname -a
orver
Linux leon-pc 6.5.0-35-generic #35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 7 09:00:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Output of
java -version
openjdk version "17.0.11" 2024-04-16 OpenJDK Runtime Environment (build 17.0.11+9-Ubuntu-122.04.1) OpenJDK 64-Bit Server VM (build 17.0.11+9-Ubuntu-122.04.1, mixed mode, sharing)
Quarkus version or git rev
3.7.3
Build tool (ie. output of
mvnw --version
orgradlew --version
)Gradle 8.5
Additional information
No response
The text was updated successfully, but these errors were encountered: