-
Notifications
You must be signed in to change notification settings - Fork 146
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
Add support for virtual workflow threads #2297
Open
Quinn-With-Two-Ns
wants to merge
11
commits into
temporalio:master
Choose a base branch
from
Quinn-With-Two-Ns:virtual-thread-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+836
−71
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6bcbae9
Add support for virtual workflow threads
Quinn-With-Two-Ns a19cacd
enable virtual workflow threads in springboot
Quinn-With-Two-Ns a1642e6
Add API key support for spring boot
Quinn-With-Two-Ns 18902dc
Allow enabling virtual threads on worker
Quinn-With-Two-Ns a968ea2
Allow virtual thread for all workers
Quinn-With-Two-Ns cd1e7ed
Fix some comments
Quinn-With-Two-Ns f288fb0
switch to usingVirtualThreads
Quinn-With-Two-Ns 5254f61
Set multi release jar on shaded module
Quinn-With-Two-Ns db48e0f
Remove API key code
Quinn-With-Two-Ns 8bdbfb3
Add worker virtual thread options to spring boot
Quinn-With-Two-Ns 2be56ce
Fix IsEnableVirtualWorkflowThreads
Quinn-With-Two-Ns File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
31 changes: 31 additions & 0 deletions
31
temporal-sdk/src/main/java/io/temporal/internal/task/ThreadConfigurator.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved. | ||
* | ||
* Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Modifications copyright (C) 2017 Uber Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this material except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.temporal.internal.task; | ||
|
||
/** | ||
* Function interface for {@link VirtualThreadDelegate#newVirtualThreadExecutor(ThreadConfigurator)} | ||
* called for every thread created. | ||
*/ | ||
@FunctionalInterface | ||
public interface ThreadConfigurator { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure you need a whole new interface for what could just be a |
||
/** Invoked for every thread created by {@link VirtualThreadDelegate#newVirtualThreadExecutor}. */ | ||
void configure(Thread t); | ||
} |
35 changes: 35 additions & 0 deletions
35
temporal-sdk/src/main/java/io/temporal/internal/task/VirtualThreadDelegate.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved. | ||
* | ||
* Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Modifications copyright (C) 2017 Uber Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this material except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.temporal.internal.task; | ||
|
||
import java.util.concurrent.ExecutorService; | ||
|
||
/** | ||
* Internal delegate for virtual thread handling on JDK 21. This is a dummy version for reachability | ||
* on JDK <21. | ||
*/ | ||
public final class VirtualThreadDelegate { | ||
public static ExecutorService newVirtualThreadExecutor(ThreadConfigurator configurator) { | ||
throw new UnsupportedOperationException("Virtual threads not supported on JDK <21"); | ||
} | ||
|
||
private VirtualThreadDelegate() {} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
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 wonder if, in addition to this, it'd also be valuable in CI to run the whole existing test suite with virtual threads on for all workflow workers. If we have tests on thread interruption or deadlock detection, I think we want to confirm they still work.
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.
Virtual threads don't behave any differently then platform threads here FWIW so I don't think it is providing a lot of value to double our CI time.
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.
We have a whole suite of different workflow logic/expectations, might as well confirm it works. I think we can run as a concurrent CI job to not double our time. I think the peace of mind is worth it. Should still have virtual-thread specific tests like these, but a whole CI run where virtual threads is enabled for everything (workflows and all 4 types of workers) would give some comfort.
Maybe even if it wasn't on in CI, even the ability to run it (e.g. some flag that changes all test workers and whatever supported plumbing needed) and confirmation that we did run it once and it works would be great.
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.
Yes that what this test suite is for if there is specific tests we can add them to this test site, but the differences between platforms and virtual threads are not enough to justify running all tests twice
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.
We can revisit this though when we mark virtual threads as non experimental
edit: revisit
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.
Yep I can do that