-
Notifications
You must be signed in to change notification settings - Fork 156
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
feat: Enhance virtual thread support #1724
Conversation
actor/src/main/scala/org/apache/pekko/dispatch/VirtualThreadSupport.scala
Outdated
Show resolved
Hide resolved
# When set to `on` but underlying runtime does not support virtual threads, an Exception will throw. | ||
# Virtualize this dispatcher as a virtual-thread-executor | ||
# Valid values are: `on`, `off` | ||
virtualize = off |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
behind an option
actor/src/main/scala/org/apache/pekko/dispatch/VirtualThreadSupportReflect.scala
Outdated
Show resolved
Hide resolved
262b627
to
fc2f4d7
Compare
actor/src/main/scala/org/apache/pekko/dispatch/VirtualThreadSupportReflect.scala
Outdated
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be written using MethodHandles. #1724 (comment)
This comment was marked as outdated.
This comment was marked as outdated.
for (_ <- 1 to 1000) { | ||
actor ! "ping" | ||
expectMsgPF() { case name: String => | ||
name should include("ForkJoinPoolVirtualThreadSpec-virtual.task-dispatcher-virtual-thread-") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it run on a virtual thread, and virtual thread is running on a CarrierThread
75bc885
to
c5fa25a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no objections to this.
...ests/src/test/scala-jdk21-only/org/apache/pekko/dispatch/ForkJoinPoolVirtualThreadSpec.scala
Outdated
Show resolved
Hide resolved
@@ -86,15 +87,28 @@ class ForkJoinExecutorConfigurator(config: Config, prerequisites: DispatcherPrer | |||
} | |||
|
|||
class ForkJoinExecutorServiceFactory( | |||
val id: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useless field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
used in createExecutorServiceFactory
, some lines below.
@Roiocam I have addressed your feedback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Thanks for review. |
Motivation:
Enhances the current virtual thread support which can switch the virtual threads' scheduler.
Modification:
Use the method handle to change the scheduler of virtual threads.
CarrierThread
Result:
Virtualization with virtual threads supported.
We have a user case at $Work, where we are pulling data from a blocking API, With this, I think we can then decrease the Threads number.
based on #1734