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
8261445: Use memory_order_relaxed for os::random(). #2484
Conversation
|
@theRealAph 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
@theRealAph This change now passes all automated pre-integration checks. 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 12 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.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems superficially fine, given unsynchronized read of _rand_seed
prior to that. But I have to wonder if in absence of any memory ordering semantics, this loop is guaranteed to terminate? That is, can't a sufficiently hostile optimizer reduce it to the CAS loop that always expects a constant "oldval" seed?
...and yes, it seems to (borderline imperceptibly) improve startup :)
|
I can't see any problem here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a nice improvement!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine to me too.
Thanks,
David
Yes, that looks fine. If we match the C++11 semantics of |
This one seems to have fallen through the cracks. @theRealAph, would you like to finish it? |
/integrate |
@theRealAph Since your change was applied there have been 984 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit a25bae8. |
os::random() is used a lot (once for every class) during HotSpot initialization, and it defaults to using a compare-and-swap operation with memory_order_conservative. We don't need that: it should be memory_order_relaxed.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/2484/head:pull/2484
$ git checkout pull/2484