Skip to content

Conversation

@parttimenerd
Copy link
Contributor

@parttimenerd parttimenerd commented Jul 15, 2025

Simple optimization to reduce busy waiting in safepoint handlers.


Progress

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

Issue

  • JDK-8358621: Reduce busy waiting in worse case at the synchronization point returning from native in CPU Time Profiler (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26314

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 15, 2025

👋 Welcome back jbechberger! 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
Copy link

openjdk bot commented Jul 15, 2025

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

8358621: Reduce busy waiting in worse case at the synchronization point returning from native in CPU Time Profiler

Reviewed-by: shade, jbachorik, egahlin

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 18 new commits pushed to the master branch:

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 rfr Pull request is ready for review label Jul 15, 2025
@openjdk
Copy link

openjdk bot commented Jul 15, 2025

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

  • hotspot-jfr

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 hotspot-jfr hotspot-jfr-dev@openjdk.org label Jul 15, 2025
@mlbridge
Copy link

mlbridge bot commented Jul 15, 2025

Webrevs

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.

There is an utility for this, look in utilities/spinYield.hpp. Would be something like:

SpinYield sy;
while (...) {
  sy.wait();
}

Also, well, this does not avoid the spinlock, it only makes it less aggressive. I read the original improvement suggested using the actual / blocking Mutex/Monitor. But that looks not great for signal-safety.

I propose we just rename the issue to something more related to the change. Also, maybe set Fix Version: 26, and then backport, to avoid complicating things unnecessarily.

@parttimenerd
Copy link
Contributor Author

Mutex / Monitor cannot be used as the lock is also used in signal handlers. I'll update to use SpinYield.

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 OK to me, as long as JFR folks are happy with this solution.

/reviewers 2

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 15, 2025
@openjdk
Copy link

openjdk bot commented Jul 15, 2025

@shipilev
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jul 15, 2025
@shipilev
Copy link
Member

Also this: "I propose we just rename the issue to something more related to the change. Also, maybe set Fix Version: 26, and then backport, to avoid complicating things unnecessarily."

@parttimenerd
Copy link
Contributor Author

Thanks. As a background: This lock should almost never be locked (confirmed with renaissance benchmark), when the safepoint handler comes in. So it is more a defence against a rare outlier.

@parttimenerd parttimenerd changed the title 8358621: Avoid using a spinlock as the synchronization point returning from native in CPU Time Profiler 8358621: Reduce busy waiting in worse case at the synchronization point returning from native in CPU Time Profiler Jul 15, 2025
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 15, 2025
@parttimenerd
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Jul 15, 2025

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

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jul 15, 2025

@parttimenerd Pushed as commit d2082c5.

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

@parttimenerd
Copy link
Contributor Author

/backport :jdk25

@openjdk
Copy link

openjdk bot commented Jul 15, 2025

@parttimenerd the backport was successfully created on the branch backport-parttimenerd-d2082c58-jdk25 in my personal fork of openjdk/jdk. To create a pull request with this backport targeting openjdk/jdk:jdk25, 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 d2082c58 from the openjdk/jdk repository.

The commit being backported was authored by Johannes Bechberger on 15 Jul 2025 and was reviewed by Aleksey Shipilev, Jaroslav Bachorik and Erik Gahlin.

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/jdk:

$ git fetch https://github.com/openjdk-bots/jdk.git backport-parttimenerd-d2082c58-jdk25:backport-parttimenerd-d2082c58-jdk25
$ git checkout backport-parttimenerd-d2082c58-jdk25
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk.git backport-parttimenerd-d2082c58-jdk25

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

Labels

hotspot-jfr hotspot-jfr-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants