-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8351927: Change VirtualThread implementation to use use FJP delayed task handling #24030
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
Closed
Closed
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
cb1aedf
In-progress snapshot
DougLea 5c4ca21
Better conform to STPE
DougLea bb0e6a6
Refactorings
DougLea f683d7f
Use pendingRemval queue
DougLea 3801ba0
Reduce unparks
DougLea d630b40
Better pending queues
DougLea 0dd4ab7
Merge branch 'openjdk:master' into JDK-8319447
DougLea 7e04af5
Conform to default STPE policies
DougLea 7288e32
Comment out racy test
DougLea b14e31c
Merge branch 'openjdk:master' into JDK-8319447
DougLea cb202b6
Reduce memory contention
DougLea 1f0a5cf
Use nanoTimeOrigin
DougLea 97a2920
Reduce nanoTime usage; extend tck tests
DougLea f9aa135
Simplify scheduler state tracking
DougLea 798fe64
Refactor delay scheduler pool submissions
DougLea d083e91
improve removal cost balance
DougLea 1a7f77c
Ensure negative nanotime offset
DougLea f832335
Merge branch 'openjdk:master' into JDK-8319447
DougLea 3da4fd7
Solidify design; add documentation
DougLea 49b1699
Separate out DelayScheduler.java
DougLea 229da14
Rework FJP-DS connections
DougLea 9fad8d4
Deal with commonPool parallelism zero; use in other juc classes; remo…
DougLea 2e60dc9
Refactor schedule methods
DougLea a0db427
Isolate screening
DougLea d0f4af1
Support STPE policy methods
DougLea a6290ab
Reduce memory accesses
DougLea c839299
Simplify policy methods; improve layout
DougLea f1394c4
Rename DelayedTask to ScheduledForkJoinTask; misc other improvements
DougLea 0e13955
Better accommodate CompletableFuture; use 4-ary heap; add javadocs; o…
DougLea 14a7a6f
Reduce garbage retention; use trailing padding; add tests
DougLea bd58f41
Merge branch 'openjdk:master' into JDK-8319447
DougLea 93aac79
Merge remote-tracking branch 'refs/remotes/origin/JDK-8319447' into J…
DougLea 753d0e0
Add optional SubmitWithTimeout action
DougLea 53516e9
Misc minor improvements and renamings for clarity
DougLea 16815cc
Address feedback
DougLea 84eaab0
Address review comments; ensure new internal methods can't clash with…
DougLea c9bc41a
Standardize parameter checking
DougLea b40513f
Address review comments; reactivation tweak
DougLea 0c5d22a
Reduce volatile reads
DougLea 5c0355b
Associate probes with carriers if Virtual (no doc updates yet)
DougLea f670910
Merge branch 'openjdk:master' into JDK-8319447
DougLea 6fe1a3b
Disambiguate caller-runs vs Interruptible
DougLea 9cc670b
Use SharedSecrets for ThreadLocalRandomProbe; other tweaks
DougLea a553179
Initial commit
AlanBateman 172a235
Reword javadoc
DougLea 9b51b7a
Use TC_MASK in accord with https://bugs.openjdk.org/browse/JDK-833001…
DougLea cfdd358
Merge branch 'pull/23702' into JDK-8351927
AlanBateman 24422e4
Match indent of naster changes
DougLea b552c22
Merge branch 'openjdk:master' into JDK-8319447
DougLea b9ce7c5
Merge branch 'pull/23702' into JDK-8351927
AlanBateman 67d77ba
Change micros to throughput in seconds
AlanBateman 9cf0a75
Address review comments
DougLea 4aabe6b
Merge branch 'openjdk:master' into JDK-8319447
DougLea a3f528d
Update
AlanBateman 3237cc7
Address review comments
DougLea b872713
Typo
DougLea f29b9f2
Merge branch 'pull/23702' into JDK-8351927
AlanBateman 50ac134
Merge
AlanBateman 700f26b
Merge branch 'master' into JDK-8351927
AlanBateman 52a9d5c
Merge branch 'master' into JDK-8351927
AlanBateman 30eba77
Merge branch 'master' into JDK-8351927
AlanBateman 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 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
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
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
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
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
98 changes: 98 additions & 0 deletions
98
test/micro/org/openjdk/bench/java/lang/VirtualThreadParking.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| /* | ||
| * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * | ||
| * This code is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU General Public License version 2 only, as | ||
| * published by the Free Software Foundation. | ||
| * | ||
| * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| * version 2 for more details (a copy is included in the LICENSE file that | ||
| * accompanied this code). | ||
| * | ||
| * You should have received a copy of the GNU General Public License version | ||
| * 2 along with this work; if not, write to the Free Software Foundation, | ||
| * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| * | ||
| * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| * or visit www.oracle.com if you need additional information or have any | ||
| * questions. | ||
| */ | ||
| package org.openjdk.bench.java.lang; | ||
|
|
||
| import java.util.concurrent.TimeUnit; | ||
| import java.util.concurrent.locks.LockSupport; | ||
| import org.openjdk.jmh.annotations.*; | ||
|
|
||
| @BenchmarkMode(Mode.Throughput) | ||
| @State(Scope.Benchmark) | ||
| @Warmup(iterations = 5, time = 10, timeUnit = TimeUnit.SECONDS) | ||
| @Measurement(iterations = 5, time = 10, timeUnit = TimeUnit.SECONDS) | ||
| @Fork(value = 3) | ||
| @OutputTimeUnit(TimeUnit.SECONDS) | ||
| public class VirtualThreadParking { | ||
|
|
||
| @Param({"100", "1000", "10000"}) | ||
| int threadCount; | ||
|
|
||
| /** | ||
| * Starts N threads that time-park, main thread unparks. | ||
| */ | ||
| @Benchmark | ||
| public void timedParkAndUnpark1() throws Exception { | ||
| var threads = new Thread[threadCount]; | ||
| var unparked = new boolean[threadCount]; | ||
| for (int i = 0; i < threadCount; i++) { | ||
| threads[i] = Thread.ofVirtual().start(() -> { | ||
| LockSupport.parkNanos(Long.MAX_VALUE); | ||
| }); | ||
| } | ||
| int remaining = threadCount; | ||
| while (remaining > 0) { | ||
| for (int i = 0; i < threadCount; i++) { | ||
| if (!unparked[i]) { | ||
| Thread t = threads[i]; | ||
| if (t.getState() == Thread.State.TIMED_WAITING) { | ||
| LockSupport.unpark(t); | ||
| unparked[i] = true; | ||
| remaining--; | ||
| } | ||
| } | ||
| } | ||
| if (remaining > 0) { | ||
| Thread.yield(); | ||
| } | ||
| } | ||
| for (Thread t : threads) { | ||
| t.join(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Starts N threads that time-park, start another N threads to unpark. | ||
| */ | ||
| @Benchmark | ||
| public void timedParkAndUnpark2() throws Exception { | ||
| var threads = new Thread[threadCount * 2]; | ||
| for (int i = 0; i < threadCount; i++) { | ||
| threads[i] = Thread.ofVirtual().start(() -> { | ||
| LockSupport.parkNanos(Long.MAX_VALUE); | ||
| }); | ||
| } | ||
| for (int i = 0; i < threadCount; i++) { | ||
| Thread thread1 = threads[i]; | ||
| Thread thread2 = Thread.ofVirtual().start(() -> { | ||
| while (thread1.getState() != Thread.State.TIMED_WAITING) { | ||
| Thread.yield(); | ||
| } | ||
| LockSupport.unpark(thread1); | ||
| }); | ||
| threads[threadCount + i] = thread2; | ||
| } | ||
| for (Thread t : threads) { | ||
| t.join(); | ||
| } | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.