Skip to content

8307483: New micros for j.u.c.LockSupport#13815

Closed
ericcaspole wants to merge 4 commits intoopenjdk:masterfrom
ericcaspole:JDK-8307483
Closed

8307483: New micros for j.u.c.LockSupport#13815
ericcaspole wants to merge 4 commits intoopenjdk:masterfrom
ericcaspole:JDK-8307483

Conversation

@ericcaspole
Copy link

@ericcaspole ericcaspole commented May 4, 2023

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

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

Reviewers

Contributors

  • Sergey Kuksenko <skuksenko@openjdk.org>

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/13815/head:pull/13815
$ git checkout pull/13815

Update a local copy of the PR:
$ git checkout pull/13815
$ git pull https://git.openjdk.org/jdk.git pull/13815/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13815

View PR using the GUI difftool:
$ git pr show -t 13815

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13815.diff

Webrev

Link to Webrev Comment

@ericcaspole
Copy link
Author

/contributor add skuksenko

@bridgekeeper
Copy link

bridgekeeper bot commented May 4, 2023

👋 Welcome back ecaspole! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label May 4, 2023
@openjdk
Copy link

openjdk bot commented May 4, 2023

@ericcaspole
Contributor Sergey Kuksenko <skuksenko@openjdk.org> successfully added.

@openjdk
Copy link

openjdk bot commented May 4, 2023

@ericcaspole The following label will be automatically applied to this pull request:

  • core-libs

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.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label May 4, 2023
@mlbridge
Copy link

mlbridge bot commented May 4, 2023

Webrevs

@Override
public void run() {
my_thread = Thread.currentThread();
while (!done) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes done must be volatile. Surprised this even worked as expected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."

Copy link
Member

@dholmes-ora dholmes-ora May 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Irrespective of park/unpark barriers, the JIT should have hoisted done and rewritten as:

if (!done) {
  while(true) {
    ...
  }
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I guess the park/unpark barriers prevented that.

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursory style reviews.

Comment on lines 111 to 113
for(int i=0; i < idle_threads.length; i++) {
new Thread(idle_threads[i] = new IdleThread()).start();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These idleThreads are not actually Thread-s, they are Runnable-s.

Suggested change
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();
}

@Override
public void run() {
my_thread = Thread.currentThread();
while (!done) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

ericcaspole and others added 2 commits May 9, 2023 13:25
Co-authored-by: Aleksey Shipilëv <shipilev@amazon.de>
@ericcaspole
Copy link
Author

I think I fixed all the commented items, could anyone look?

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay, with a few remaining nits.

@openjdk
Copy link

openjdk bot commented May 17, 2023

@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:

8307483: New micros for j.u.c.LockSupport

Co-authored-by: Sergey Kuksenko <skuksenko@openjdk.org>
Reviewed-by: shade, redestad

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 master branch:

  • 6d4782b: 8307976: (fs) Files.createDirectories(dir) returns dir::toAbsolutePath instead of dir
  • f57c783: 8308239: Tighten up accessibility of nested classes in java.lang.invoke
  • 64f6681: 8308246: PPC64le build broken after JDK-8304913
  • 5763be7: 8307326: Package jdk.internal.classfile.java.lang.constant become obsolete
  • c7951cf: 8306304: Fix xlc17 clang warnings in ppc and aix code
  • 285c833: 8308043: Deadlock in TestCSLocker.java due to blocking GC while allocating
  • 1a6f981: 8308185: Update Http2TestServerConnection to use SSLSocket.startHandshake()
  • b300e73: 8308088: Improve class check in CollectedHeap::is_oop
  • e34ecc9: 8296469: Instrument VMError::report with reentrant iteration step for register and stack printing
  • 5a92aae: 8308156: VerifyCACerts.java misses blank in error output
  • ... and 194 more: https://git.openjdk.org/jdk/compare/a87262efb2c0f5ed1773533d69d7d2091eba1462...master

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 17, 2023
Copy link
Member

@cl4es cl4es left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with @shipilev's suggestions

Apply Aleksey's suggestions of May 17

Co-authored-by: Aleksey Shipilëv <shipilev@amazon.de>
@ericcaspole
Copy link
Author

/integrate

Thanks Claes and Aleksey!

@openjdk
Copy link

openjdk bot commented May 17, 2023

Going to push as commit 6073edf.
Since your change was applied there have been 207 commits pushed to the master branch:

  • 2409448: 8307365: JvmtiStressModule hit SIGSEGV in JvmtiEventControllerPrivate::recompute_thread_enabled
  • 950c5df: 8307299: Move more DnD tests to open
  • 8bedf2e: 8308292: Problemlist vmTestbase/nsk/jvmti/AttachOnDemand/attach020/TestDescription.java
  • 6d4782b: 8307976: (fs) Files.createDirectories(dir) returns dir::toAbsolutePath instead of dir
  • f57c783: 8308239: Tighten up accessibility of nested classes in java.lang.invoke
  • 64f6681: 8308246: PPC64le build broken after JDK-8304913
  • 5763be7: 8307326: Package jdk.internal.classfile.java.lang.constant become obsolete
  • c7951cf: 8306304: Fix xlc17 clang warnings in ppc and aix code
  • 285c833: 8308043: Deadlock in TestCSLocker.java due to blocking GC while allocating
  • 1a6f981: 8308185: Update Http2TestServerConnection to use SSLSocket.startHandshake()
  • ... and 197 more: https://git.openjdk.org/jdk/compare/a87262efb2c0f5ed1773533d69d7d2091eba1462...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 17, 2023
@openjdk openjdk bot closed this May 17, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 17, 2023
@openjdk
Copy link

openjdk bot commented May 17, 2023

@ericcaspole Pushed as commit 6073edf.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

6 participants