Skip to content
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

8301341: LinkedTransferQueue does not respect timeout for poll() #14317

Closed
wants to merge 13 commits into from

Conversation

DougLea
Copy link
Contributor

@DougLea DougLea commented Jun 5, 2023

This update addresses performance issues across both LinkedTransferQueue and SynchronousQueue by creating a common basis for implementation across them (mainly in LinkedTransferQueue). Pasting from internal doc summary of changes:
* * Class DualNode replaces Qnode, with fields and methods
* that apply to any match-based dual data structure, and now
* usable in other j.u.c classes. in particular, SynchronousQueue.
* * Blocking control (in class DualNode) accommodates
* VirtualThreads and (perhaps virtualized) uniprocessors.
* * All fields of this class (LinkedTransferQueue) are
* default-initializable (to null), allowing further extension
* (in particular, SynchronousQueue.Transferer)
* * Head and tail fields are lazily initialized rather than set
* to a dummy node, while also reducing retries under heavy
* contention and misorderings, and relaxing some accesses,
* requiring accommodation in many places (as well as
* adjustments in WhiteBox tests).


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

Issues

  • JDK-8301341: LinkedTransferQueue does not respect timeout for poll() (Bug - P4)
  • JDK-8300663: java/util/concurrent/SynchronousQueue/Fairness.java failed with "Error: fair=true i=0 j=1" (Bug - P3)
  • JDK-8267502: JDK-8246677 caused 16x performance regression in SynchronousQueue (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14317

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 5, 2023

👋 Welcome back dl! 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 Jun 5, 2023
@openjdk
Copy link

openjdk bot commented Jun 5, 2023

@DougLea 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 Jun 5, 2023
@mlbridge
Copy link

mlbridge bot commented Jun 5, 2023

Copy link
Contributor

@AlanBateman AlanBateman left a comment

Choose a reason for hiding this comment

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

This looks okay to me, it was a bit easier than I expected.

The only comment I have is an interrupt while spinning won't be noticed until count goes to 0, that should be rare enough that it doesn't matter. We might have to tune SPIN_FOR_TIMEOUT_THRESHOLD at some point for virtual threads.

@openjdk
Copy link

openjdk bot commented Jun 6, 2023

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

8301341: LinkedTransferQueue does not respect timeout for poll()
8300663: java/util/concurrent/SynchronousQueue/Fairness.java failed with "Error: fair=true i=0 j=1"
8267502: JDK-8246677 caused 16x performance regression in SynchronousQueue

Reviewed-by: alanb

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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 Jun 6, 2023
@viktorklang-ora
Copy link
Contributor

@DougLea @AlanBateman I had a look as well, didn't find anything to comment on. 👍

Copy link
Contributor

@viktorklang-ora viktorklang-ora left a comment

Choose a reason for hiding this comment

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

Need to digest this a bit. Will give more concrete feedback ASAP :)

@DougLea
Copy link
Contributor Author

DougLea commented Jul 20, 2023

/issue JDK-8300663

@DougLea
Copy link
Contributor Author

DougLea commented Jul 20, 2023

/issue JDK-8267502

@openjdk
Copy link

openjdk bot commented Jul 20, 2023

@DougLea
Adding additional issue to issue list: 8300663: java/util/concurrent/SynchronousQueue/Fairness.java failed with "Error: fair=true i=0 j=1".

@openjdk
Copy link

openjdk bot commented Jul 20, 2023

@DougLea
Adding additional issue to issue list: 8267502: JDK-8246677 caused 16x performance regression in SynchronousQueue.

@DougLea
Copy link
Contributor Author

DougLea commented Jul 20, 2023

A backport note: This set of changes may be applied jdk19+ by removing only the lines (currently L423-424) in LinkedTransferQueue:
if w.isVirtual()) // don't spin
spin = false;

@DougLea
Copy link
Contributor Author

DougLea commented Jul 22, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Jul 22, 2023

Going to push as commit 8d1ab57.
Since your change was applied there have been 3 commits pushed to the master branch:

  • bfa76df: 8311978: Shenandoah: Create abstraction over heap metrics for heuristics
  • 3c644dc: 8312044: Simplify toolkit Builder/Writer world
  • f4ba7b2: 8312414: Make java.util.ServiceLoader.LANG_ACCESS final

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jul 22, 2023

@DougLea Pushed as commit 8d1ab57.

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

@DougLea DougLea deleted the JDK-8301341 branch July 24, 2023 21:23
@wborn
Copy link

wborn commented Aug 6, 2023

Thanks for making the fixes Doug!
Would it also be possible to backport these fixes to Java 17?

It seems to be a very common issue for openHAB users now that they upgrade to openHAB 4 which requires Java 17.

See:

HolgerHees added a commit to HolgerHees/smartserver that referenced this pull request Aug 9, 2023
@DougLea
Copy link
Contributor Author

DougLea commented Aug 10, 2023

@wborn I think 17 should also be OK modulo deleting 2 lines for pre-21 mentioned above. I only checked with 19 though..

@robm-openjdk
Copy link
Member

/backport jdk21u

@openjdk
Copy link

openjdk bot commented Sep 15, 2023

@robm-openjdk the backport was successfully created on the branch robm-openjdk-backport-8d1ab570 in my personal fork of openjdk/jdk21u. To create a pull request with this backport targeting openjdk/jdk21u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 8d1ab570 from the openjdk/jdk repository.

The commit being backported was authored by Doug Lea on 22 Jul 2023 and was reviewed by Alan Bateman.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u:

$ git fetch https://github.com/openjdk-bots/jdk21u.git robm-openjdk-backport-8d1ab570:robm-openjdk-backport-8d1ab570
$ git checkout robm-openjdk-backport-8d1ab570
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u.git robm-openjdk-backport-8d1ab570

@suryag10
Copy link

suryag10 commented Jul 2, 2024

@DougLea is there any timeline where we can expect the backport of this fix into jdk17? or any other work around?

@DougLea
Copy link
Contributor Author

DougLea commented Jul 2, 2024

@suryag10 Sorry I'm not the right person to ask about backports.

@jaikiran
Copy link
Member

jaikiran commented Jul 3, 2024

Like Doug notes, the JDK backports are managed as a separate project. Details are available here https://openjdk.org/projects/jdk-updates/. For JDK 17 the corresponding project is https://wiki.openjdk.org/display/JDKUpdates/JDK+17u which has the necessary details about the process as well as the mailing list details where you can bring up the backporting question.

@suryag10
Copy link

suryag10 commented Jul 3, 2024

Thanks for the info @DougLea and @jaikiran

@viktorklang-ora
Copy link
Contributor

Just my 2 cents—given the size of this change, I'd be hesitant to have it backported. Also, more than this PR would need to be backported, for instance: #19271

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.

8 participants