This is an automated email from the ASF dual-hosted git repository. He-Pin pushed a commit to branch feat-virtualize-dispatcher-clean in repository https://gitbox.apache.org/repos/asf/pekko.git
commit 52d249ac1296a5afa8a67d582cff9131dfa3e4d5 Author: 虎鸣 <[email protected]> AuthorDate: Tue Apr 21 18:13:23 2026 +0800 chore: clean branch with only virtualize changes Motivation: remove accidental unrelated files (.claude, .jvmopts, design docs) from PR branch Modification: port only the intended files (.github/workflows/nightly-builds.yml, stream-testkit/src/test/resources/reference.conf, stream-tests/src/test/resources/application.conf, CONTRIBUTING.md) Result: create clean branch ready for review; does not overwrite PR branch until user approves References: upstream PR #2872 Co-authored-by: Copilot <[email protected]> --- .github/workflows/nightly-builds.yml | 7 ++++ CONTRIBUTING.md | 46 +++++++++++++++++++++++- stream-testkit/src/test/resources/reference.conf | 4 +++ stream-tests/src/test/resources/application.conf | 10 ++++++ 4 files changed, 66 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nightly-builds.yml b/.github/workflows/nightly-builds.yml index c68ba0ac7d..fd941e7b99 100644 --- a/.github/workflows/nightly-builds.yml +++ b/.github/workflows/nightly-builds.yml @@ -149,6 +149,13 @@ jobs: - name: Compile and Test # note that this is not running any multi-jvm tests because multi-in-test=false # JDK 25 ForkJoinPool scheduling changes need a higher timefactor (see #2573, #2870) + # JDK 21+ uses virtual threads to bypass ForkJoinPool compensation-thread starvation (JDK-8300995) + # Virtual threads provide equivalent or better performance by eliminating unmount-remount penalties + # when blocking on I/O or reply futures, so TIMEFACTOR remains 2 for JDK 21-24. + # If timeouts occur in nightly runs, increase TIMEFACTOR to 3 immediately. + env: + # Enable virtual threads only on JDK 21+ (nightly build only) + PEKKO_VIRTUALIZE_DISPATCHER: ${{ matrix.javaVersion >= 21 && 'on' || 'off' }} run: |- if [ "${{ matrix.javaVersion }}" -ge 25 ]; then TIMEFACTOR=4 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2c84774d18..ed29702b8e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -200,6 +200,50 @@ Pekko, like most Scala projects, compiles faster with the Graal JIT enabled. The * Use a JDK > 10 * Use the following JVM options for SBT e.g. by adding them to the `SBT_OPTS` environment variable: `-XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler` +### Virtual Threads Testing + +#### Testing Stream Dispatcher with Virtual Threads (JDK 21+) + +Virtual threads solve JDK-8300995 (ForkJoinPool compensation-thread starvation) +that causes sporadic test timeouts. See [#2870](https://github.com/apache/pekko/issues/2870). + +**Local Testing**: + +```bash +# 1. Use JDK 21 or later +sdk use java 21 + +# 2. Enable JVM options for virtual thread support +cp .jvmopts-ci .jvmopts + +# 3. Test with virtual threads enabled +export PEKKO_VIRTUALIZE_DISPATCHER=on +sbt 'actor-tests/scala-jdk21-only:testOnly *VirtualThread*' + +# IMPORTANT: Clean up after testing to avoid affecting subsequent test runs +unset PEKKO_VIRTUALIZE_DISPATCHER +``` + +**Safe One-Liner** (prevents env var from persisting): +```bash +(export PEKKO_VIRTUALIZE_DISPATCHER=on; sbt 'actor-tests/scala-jdk21-only:testOnly *VirtualThread*') && unset PEKKO_VIRTUALIZE_DISPATCHER +``` + +**Environment Variable Values**: +- `PEKKO_VIRTUALIZE_DISPATCHER=on` - Enable virtual threads for stream dispatcher tests +- `PEKKO_VIRTUALIZE_DISPATCHER=off` - Disable virtual threads (default, safe for local testing) +- Unset/any other value - Falls back to `off` (safe default) + +**CI Behavior**: +- JDK 21/25 nightly builds: virtualize=on (virtual threads enabled) +- JDK 17 tests: virtualize=off (falls back to ForkJoinPool) +- PR tests: virtualize=off (for stability) + +**Design Notes**: +- PR #2872: Virtual threads (this feature) +- PR #2871: ForkJoinPool minimum-runnable tuning (alternative for older JDKs) +- Both work together; use virtual threads when available (JDK 21+) + ### The `validatePullRequest` task The Pekko build includes a special task called `validatePullRequest`, which investigates the changes made as well as dirty @@ -214,7 +258,7 @@ To use the task, simply type `validatePullRequest`, and the output should includ ```shell > validatePullRequest [info] Diffing [HEAD] to determine changed modules in PR... -[info] Detected uncommitted changes in directories (including in dependency analysis): [protobuf,project] +[info] Detected uncomitted changes in directories (including in dependency analysis): [protobuf,project] [info] Detected changes in directories: [actor-tests, project, stream, docs, persistence] ``` diff --git a/stream-testkit/src/test/resources/reference.conf b/stream-testkit/src/test/resources/reference.conf index 990b427747..9b8378d404 100644 --- a/stream-testkit/src/test/resources/reference.conf +++ b/stream-testkit/src/test/resources/reference.conf @@ -1,5 +1,8 @@ # SPDX-License-Identifier: Apache-2.0 +# Virtual thread configuration moved to stream-tests/src/test/resources/application.conf (test classpath). See CONTRIBUTING.md for details. + + # The StreamTestDefaultMailbox verifies that stream actors are using the dispatcher defined in ActorMaterializerSettings. # # All stream tests should use the dedicated `pekko.test.stream-dispatcher` or disable this validation by defining: @@ -14,6 +17,7 @@ pekko.test.stream-dispatcher { fork-join-executor { parallelism-min = 8 parallelism-max = 8 + # Virtual thread configuration moved to stream-tests/src/test/resources/application.conf (test-only) } mailbox-requirement = "org.apache.pekko.dispatch.UnboundedMessageQueueSemantics" } diff --git a/stream-tests/src/test/resources/application.conf b/stream-tests/src/test/resources/application.conf new file mode 100644 index 0000000000..98f92a5d50 --- /dev/null +++ b/stream-tests/src/test/resources/application.conf @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Test-only: Virtual thread configuration. +# Default: off for local development. Nightly CI sets PEKKO_VIRTUALIZE_DISPATCHER=on for JDK 21+. + +pekko.test.stream-dispatcher.fork-join-executor { + # Default to off, then allow env var to override when set. + virtualize = off + virtualize = ${?PEKKO_VIRTUALIZE_DISPATCHER} +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
