feat: make ForkJoinPool minimum-runnable configurable and improve pool documentation#2871
Merged
feat: make ForkJoinPool minimum-runnable configurable and improve pool documentation#2871
Conversation
This was referenced Apr 18, 2026
…21+ starvation Motivation: PekkoForkJoinPool hard-coded minimumRunnable=1 in the JDK 9+ ForkJoinPool constructor. This is the threshold below which the pool creates compensation threads to maintain progress. On JDK 21+ (see JDK-8300995 / JDK-8321335), the compensation-thread mechanism for asyncMode=FIFO pools became more conservative, making it harder to recover from actor-heavy workloads where the single "runnable" threshold is insufficient under load. Modification: - Added minimum-runnable = 1 to fork-join-executor in reference.conf (default preserves existing behaviour; documented relationship to JDK-8300995). - PekkoForkJoinPool now accepts minimumRunnable as a constructor parameter (default 1 for binary compatibility). - ForkJoinExecutorServiceFactory reads minimum-runnable from config and forwards it to PekkoForkJoinPool. Result: Users experiencing dispatcher starvation on JDK 21+ can now increase minimum-runnable (e.g. to parallelism/2) to prompt earlier compensation- thread creation without needing to patch Pekko itself. All existing actor-tests/dispatch tests pass unchanged (71 passed, 1 pending). Fixes: #2870 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…on thread behavior Motivation: The previous comment was minimal and did not explain how maximum-pool-size interacts with ForkJoinPool compensation threads on JDK 21+. Modification: Expand the maximum-pool-size comment to describe that on JDK 21+ the pool uses this as a cap for compensation threads. Tuning it closer to the target parallelism can reduce latency under actor-heavy workloads (see JDK-8300995 tracked in #2870). Result: Users who see JDK 21+ ForkJoinPool scheduling jitter now have actionable guidance directly in the default configuration. References: #2870 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
d0d208f to
75e6540
Compare
This was referenced Apr 21, 2026
He-Pin
added a commit
that referenced
this pull request
Apr 21, 2026
Motivation: JDK-8300995 causes ForkJoinPool compensation-thread starvation, leading to sporadic test timeouts when actors block on reply futures. Virtual threads (JDK 21+) bypass this limitation by unmounting when blocking, providing equivalent or better performance. See issue #2870. Modification: 1. stream-testkit/reference.conf: Add PEKKO_VIRTUALIZE_DISPATCHER env var support with safe fallback to 'off' for stable local testing 2. .github/workflows/nightly-builds.yml: Set env var conditionally for JDK 21+, with detailed comments explaining TIMEFACTOR logic 3. CONTRIBUTING.md: Document virtual thread testing with cleanup guidance and safe one-liner for developers 4. Virtual thread enablement only affects nightly CI on JDK 21+; local development defaults to OFF for stability Result: - Virtual threads automatically enabled on JDK 21+ in nightly builds - Local tests safely default to virtual threads OFF for stability - Nightly test reliability improved; timeouts addressed - Binary compatibility maintained; MiMa checks pass References: - Issue #2870: Compensation-thread starvation investigation - Issue #2573: JDK 25 ForkJoinPool scheduling regression - PR #2871: ForkJoinPool minimum-runnable tuning (JDK < 21 fallback) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
5 tasks
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.
Summary
Two targeted improvements to the ForkJoinPool executor configuration — no behavior change by default, purely additive.
Changes
1. Configurable
minimum-runnableactor/src/main/resources/reference.confactor/src/main/scala/org/apache/pekko/dispatch/ForkJoinExecutorConfigurator.scalaPekkoForkJoinPoolnow acceptsminimumRunnable: Int = 1ForkJoinExecutorServiceFactoryreadsminimum-runnablefrom config1is identical to the previously hardcoded value — no behavior changeparallelism / 2) to prompt faster compensation-thread creationBinary compatibility: new params carry default values; class is
@InternalApi, so MiMa exclusion is not required.2. Improved
maximum-pool-sizedocumentationThe existing comment was minimal. The new comment explains that on JDK 21+:
maximum-pool-sizeminimum-runnablehelps under heavy actor-round-trip workloadsWhat this PR does NOT change
minimum-runnable = 1preserves existing behaviourRelated
virtualize = oninvestigation