8307483: New micros for j.u.c.LockSupport#13815
8307483: New micros for j.u.c.LockSupport#13815ericcaspole wants to merge 4 commits intoopenjdk:masterfrom
Conversation
|
/contributor add skuksenko |
|
👋 Welcome back ecaspole! A progress list of the required criteria for merging this PR into |
|
@ericcaspole |
|
@ericcaspole The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
| @Override | ||
| public void run() { | ||
| my_thread = Thread.currentThread(); | ||
| while (!done) { |
There was a problem hiding this comment.
You might want to re-check IdleThread. From a quick look I would have expected "done" to be volatile. Also "my_thread" as it is set in the run with plain access.
There was a problem hiding this comment.
Yes done must be volatile. Surprised this even worked as expected.
There was a problem hiding this comment.
Same as we saw with isAlive before: LockSupport.park implicitly provides a compiler barrier. This done should be at least "opaque" to carry the same effect.
There was a problem hiding this comment.
Yes, park() and unpark() having release and acquire semantics is not documented here, and the documentation for LockSupport explicitly says "Reliable usage requires the use of volatile (or atomic) variables to control when to park or unpark. Orderings of calls to these methods are maintained with respect to volatile variable accesses, but not necessarily non-volatile variable accesses."
There was a problem hiding this comment.
Irrespective of park/unpark barriers, the JIT should have hoisted done and rewritten as:
if (!done) {
while(true) {
...
}
}
There was a problem hiding this comment.
Well I guess the park/unpark barriers prevented that.
test/micro/org/openjdk/bench/java/util/concurrent/UnparkBenchSleepersAfter.java
Outdated
Show resolved
Hide resolved
test/micro/org/openjdk/bench/java/util/concurrent/UnparkBenchSleepersAfter.java
Outdated
Show resolved
Hide resolved
| for(int i=0; i < idle_threads.length; i++) { | ||
| new Thread(idle_threads[i] = new IdleThread()).start(); | ||
| } |
There was a problem hiding this comment.
These idleThreads are not actually Thread-s, they are Runnable-s.
| for(int i=0; i < idle_threads.length; i++) { | |
| new Thread(idle_threads[i] = new IdleThread()).start(); | |
| } | |
| for(int i = 0; i < idles; i++) { | |
| Runnable r = new IdleRunnable(); | |
| idleRunnables[i] = r; | |
| new Thread(r).start(); | |
| } |
test/micro/org/openjdk/bench/java/util/concurrent/UnparkBenchSleepersAfter.java
Outdated
Show resolved
Hide resolved
test/micro/org/openjdk/bench/java/util/concurrent/UnparkBenchSleepersAfter.java
Outdated
Show resolved
Hide resolved
| @Override | ||
| public void run() { | ||
| my_thread = Thread.currentThread(); | ||
| while (!done) { |
There was a problem hiding this comment.
Same as we saw with isAlive before: LockSupport.park implicitly provides a compiler barrier. This done should be at least "opaque" to carry the same effect.
Co-authored-by: Aleksey Shipilëv <shipilev@amazon.de>
|
I think I fixed all the commented items, could anyone look? |
shipilev
left a comment
There was a problem hiding this comment.
Looks okay, with a few remaining nits.
test/micro/org/openjdk/bench/java/util/concurrent/UnparkBenchSleepersBefore.java
Outdated
Show resolved
Hide resolved
test/micro/org/openjdk/bench/java/util/concurrent/UnparkBenchSleepersBefore.java
Outdated
Show resolved
Hide resolved
test/micro/org/openjdk/bench/java/util/concurrent/UnparkBenchSleepersBefore.java
Outdated
Show resolved
Hide resolved
test/micro/org/openjdk/bench/java/util/concurrent/UnparkBenchSleepersAfter.java
Outdated
Show resolved
Hide resolved
test/micro/org/openjdk/bench/java/util/concurrent/UnparkBenchSleepersAfter.java
Outdated
Show resolved
Hide resolved
|
@ericcaspole This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 204 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
Apply Aleksey's suggestions of May 17 Co-authored-by: Aleksey Shipilëv <shipilev@amazon.de>
|
/integrate Thanks Claes and Aleksey! |
|
Going to push as commit 6073edf.
Your commit was automatically rebased without conflicts. |
|
@ericcaspole Pushed as commit 6073edf. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
These micros were developed while investigating JDK-8305670 by myself and Sergey Kuksenko. The order of thread creation was important in that bug, so there are 2 JMH for creating sleepers before and after the worker threads.
Progress
Issue
Reviewers
Contributors
<skuksenko@openjdk.org>Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/13815/head:pull/13815$ git checkout pull/13815Update a local copy of the PR:
$ git checkout pull/13815$ git pull https://git.openjdk.org/jdk.git pull/13815/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 13815View PR using the GUI difftool:
$ git pr show -t 13815Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13815.diff
Webrev
Link to Webrev Comment