[Feature] Support Virtual Threads#908
Open
devingryu wants to merge 3 commits intoconfluentinc:masterfrom
Open
Conversation
* Added boolean useVirtualThreads in ParallelConsumerOptions * Generalize workerThreadPool logics to handle Virtual Threads * Added tests
* prevents virtual threads pinning
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.
Adds option to use Virtual Threads for worker pool. (See also: #896)
useVirtualThreadsoption and execution logic to support Java 21+ Virtual Threads (Project Loom).synchronizedblocks toReentrantLockto prevent VT pinning.setupWorkerPooltoExecutorServiceand improved queue management and backpressure logic accordingly.Concerns
Test Environment Compatibility
The newly added VT-related tests require JDK 21+ and are configured to skip execution using
Assumptionsif the environment does not support it. It seems that current CI environment is based on JDK 17, if so the tests I added will be skipped in CI.Concurrency in
isPoolQueueLowWhen VT mode is enabled, we cannot directly query the queue size, so
WorkerManager.numberRecordsOutForProcessingis used to calculate the load. Please review if this approach creates any potential concurrency issues in a multi-threaded environment.Defensive Logic
To ensure the stability of the existing logic, if VT is disabled (
!useVirtualThreads),setupWorkerPoolis enforced to return aThreadPoolExecutor(throwing an exception otherwise), and type checks have been added. I am concerned this might introduce a breaking change (compatibility issue) for existing users who inheritAbstractParallelEoSStreamProcessorto use custom Executors.Checklist