Skip to content

feat: virtual thread support - #3603

Open
csviri wants to merge 4 commits into
operator-framework:nextfrom
csviri:virtual-threads
Open

csviri wants to merge 4 commits into
operator-framework:nextfrom
csviri:virtual-threads

Conversation

@csviri

@csviri csviri commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Introduces feature flag to use virtual threads instead of standard ThreadPool. The concurrency limit also applies for this this new mode.

Signed-off-by: Attila Mészáros a_meszaros@apple.com

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 7, 2026
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: ecdadcd0-a73d-4f61-a782-9a4b5e0e4cf4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@csviri csviri changed the title feat: virtual thread support [WIP] feat: virtual thread support Sep 7, 2026
@csviri csviri linked an issue Sep 9, 2026 that may be closed by this pull request
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
@csviri
csviri marked this pull request as ready for review September 17, 2026 06:52
Copilot AI lite review requested due to automatic review settings September 17, 2026 06:52
@openshift-ci
openshift-ci Bot requested review from metacosm and xstefank September 17, 2026 06:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds optional Java 21 virtual-thread execution support while preserving configured concurrency limits and Java 17 compatibility.

Changes:

  • Adds virtual-thread configuration and property loading.
  • Implements bounded and unbounded virtual-thread executors with fallback behavior.
  • Adds unit, integration, and documentation coverage.
File summaries
File Description
operator-framework/src/test/java/io/javaoperatorsdk/operator/config/loader/ConfigLoaderTest.java Updated as part of this pull request.
operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/virtualthreads/VirtualThreadsTestReconciler.java Updated as part of this pull request.
operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/virtualthreads/VirtualThreadsIT.java Updated as part of this pull request.
operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/virtualthreads/VirtualThreadsCustomResource.java Updated as part of this pull request.
operator-framework/src/main/java/io/javaoperatorsdk/operator/config/loader/ConfigLoader.java Updated as part of this pull request.
operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/VirtualThreadsTest.java Updated as part of this pull request.
operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java Updated as part of this pull request.
operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/VirtualThreads.java Updated as part of this pull request.
operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ExecutorServiceManager.java Updated as part of this pull request.
operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverrider.java Updated as part of this pull request.
operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java Updated as part of this pull request.
docs/content/en/docs/documentation/operations/configuration.md Updated as part of this pull request.
Review details

Suppressed comments (1)

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/VirtualThreads.java:143

  • This implementation creates and parks one virtual thread for every submitted task before acquiring a permit. Unlike the previous fixed pool, a large reconciliation backlog therefore becomes one live virtual-thread object per queued event, so a burst or outage can consume substantial heap/thread-scheduler resources even though only maxConcurrency tasks execute. Please use a bounded dispatcher/queue (or otherwise cap pending submissions) so the concurrency limit also bounds resource usage, rather than relying on virtual threads being cheap.
      delegate.execute(
          () -> {
            try {
              permits.acquire();
  • Files reviewed: 12/12 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +132 to +135
private BoundedExecutorService(ExecutorService delegate, int maxConcurrency) {
this.delegate = delegate;
// fair, so that tasks run roughly in submission order as they would on a thread pool
this.permits = new Semaphore(maxConcurrency, true);
@csviri
csviri requested a lite review from Copilot September 17, 2026 07:17
@csviri csviri changed the title [WIP] feat: virtual thread support feat: virtual thread support Sep 17, 2026
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Address the shutdown/cancellation defect, reject zero concurrency limits, and clarify the scheduled-executor documentation.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (2)

docs/content/en/docs/documentation/operations/configuration.md:37

  • This says that all framework internal housekeeping runs on virtual threads, but ExecutorServiceManager deliberately keeps scheduledExecutorService on platform threads even when the flag is enabled (see ExecutorServiceManager.java:171-173). Please narrow this statement to the executors that are switched, or explicitly mention the scheduled executor exception so the user-facing documentation matches the implementation.
When enabled, reconciliations, dependent resource workflows and the framework's internal
housekeeping (starting the informers, for example) all run on virtual threads.

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/VirtualThreads.java:135

  • Unlike Executors.newFixedThreadPool, this constructor accepts maxConcurrency == 0 because Semaphore(0) is valid. Every submitted task then blocks forever waiting for a permit, so the new public ExecutorServiceManager.newBoundedExecutorService(0, true) can silently create a permanently hanging executor instead of rejecting the invalid limit. Validate that the limit is at least 1 before creating the semaphore (and keep the behavior consistent with the platform-backed path).
    private BoundedExecutorService(ExecutorService delegate, int maxConcurrency) {
      this.delegate = delegate;
      // fair, so that tasks run roughly in submission order as they would on a thread pool
      this.permits = new Semaphore(maxConcurrency, true);
  • Files reviewed: 12/12 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines +167 to +169
public List<Runnable> shutdownNow() {
return delegate.shutdownNow();
}
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>

@xstefank xstefank left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving because I know that I will be probably only one against a global virtual thread flag here.

But maybe you want to wait for our next JUG session :) - https://www.meetup.com/brno-java-meetup/events/316579260/?eventOrigin=group_upcoming_events


private BoundedExecutorService(ExecutorService delegate, int maxConcurrency) {
this.delegate = delegate;
// fair, so that tasks run roughly in submission order as they would on a thread pool

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like a piece of agent communication rather than useful comment

@csviri

csviri commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator Author

Approving because I know that I will be probably only one against a global virtual thread flag here.

But maybe you want to wait for our next JUG session :) - https://www.meetup.com/brno-java-meetup/events/316579260/?eventOrigin=group_upcoming_events

What would you propose as an alternative?

Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Virtual Threads

3 participants