feat: Enhance virtual thread support #1724
Merged
He-Pin merged 1 commit intoapache:mainfrom Jan 22, 2025
Merged
Conversation
He-Pin
commented
Jan 17, 2025
actor/src/main/scala/org/apache/pekko/dispatch/VirtualThreadSupport.scala
Outdated
Show resolved
Hide resolved
He-Pin
commented
Jan 17, 2025
| # 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 |
He-Pin
commented
Jan 17, 2025
actor/src/main/scala/org/apache/pekko/dispatch/VirtualThreadSupportReflect.scala
Outdated
Show resolved
Hide resolved
He-Pin
commented
Jan 17, 2025
262b627 to
fc2f4d7
Compare
He-Pin
commented
Jan 17, 2025
He-Pin
commented
Jan 17, 2025
pjfanning
reviewed
Jan 17, 2025
actor/src/main/scala/org/apache/pekko/dispatch/VirtualThreadSupportReflect.scala
Outdated
Show resolved
Hide resolved
Member
Author
|
|
pjfanning
requested changes
Jan 17, 2025
Member
pjfanning
left a comment
There was a problem hiding this comment.
I think this can be written using MethodHandles. #1724 (comment)
This comment was marked as outdated.
This comment was marked as outdated.
75bc885 to
c5fa25a
Compare
Roiocam
reviewed
Jan 21, 2025
Member
Roiocam
left a comment
There was a problem hiding this comment.
I have no objections to this.
...ests/src/test/scala-jdk21-only/org/apache/pekko/dispatch/ForkJoinPoolVirtualThreadSpec.scala
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| class ForkJoinExecutorServiceFactory( | ||
| val id: String, |
Member
Author
There was a problem hiding this comment.
used in createExecutorServiceFactory, some lines below.
Member
Author
|
@Roiocam I have addressed your feedback |
pjfanning
reviewed
Jan 22, 2025
pjfanning
reviewed
Jan 22, 2025
pjfanning
reviewed
Jan 22, 2025
pjfanning
reviewed
Jan 22, 2025
pjfanning
reviewed
Jan 22, 2025
pjfanning
reviewed
Jan 22, 2025
pjfanning
reviewed
Jan 22, 2025
pjfanning
reviewed
Jan 22, 2025
pjfanning
reviewed
Jan 22, 2025
Member
Author
|
Thanks for review. |
|
@He-Pin do you happen to have any performance comparison between enable virtual threads or not? |
Member
Author
|
It only help when you are working with some blocking.... |
|
got it, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
CarrierThreadResult:
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