Skip to content

8272573: Redundant unique_concrete_method_4 dependencies #5141

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

Closed
wants to merge 3 commits into from

Conversation

iwanowww
Copy link
Contributor

@iwanowww iwanowww commented Aug 17, 2021

Equivalence checks in Dependencies::assert_common_4() are too strong which leads to unique_concrete_method_4 dependencies being repeatedly recorded and duplicating nmethod dependencies registered.

The underlying problem is note_dep_seen() mutates internal bitmap, but the nested checks fail fast.
So, multiple requests are required to populate the bit-map for all the arguments in order to make the detection of duplicate assertions work. And it leads to duplicate dependencies registered.

It turns out call_site_target_value is also affected in a similar manner (see Dependencies::assert_common_2 for dependencies without explicit context argument), so I fix it along the way.

Testing: hs-tier1 - hs-tier6


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8272573: Redundant unique_concrete_method_4 dependencies

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5141/head:pull/5141
$ git checkout pull/5141

Update a local copy of the PR:
$ git checkout pull/5141
$ git pull https://git.openjdk.java.net/jdk pull/5141/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5141

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5141.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 17, 2021

👋 Welcome back vlivanov! 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 Aug 17, 2021

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

  • hotspot-compiler

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-compiler hotspot-compiler-dev@openjdk.org label Aug 17, 2021
@iwanowww iwanowww marked this pull request as ready for review August 17, 2021 18:35
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 17, 2021
@mlbridge
Copy link

mlbridge bot commented Aug 17, 2021

Webrevs

if (note_dep_seen(dept, x0) && note_dep_seen(dept, x1)) {
if (note_dep_seen(dept, x0)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why x0 is special in all these cases?
Should we do || instead?

  if (note_dep_seen(dept, x0) || note_dep_seen(dept, x1)) {

Copy link
Contributor Author

@iwanowww iwanowww Aug 17, 2021

Choose a reason for hiding this comment

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

It's just a fast path approximate check which guards linear search over recorded dependencies.
note_dep_seen(dept, x0) == false says that such a dependency argument hasn't been seen before, but note_dep_seen(dept, x0) == true requires a search over recorded dependencies to prove the argument is in the right position.

Another way to fix it is to perform all the queries beforehand:

bool dep_seen_x0 = note_dep_seen(dept, x0);
bool dep_seen_x1 = note_dep_seen(dept, x1);
if (dep_seen_x0 && dep_seen_x1) {
  ...
}

It should dramatically reduce the rate of false positives.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed the implementation which checks all the arguments. Let me know what you prefer.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Yes, I like it.

@openjdk
Copy link

openjdk bot commented Aug 17, 2021

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

8272573: Redundant unique_concrete_method_4 dependencies

Reviewed-by: kvn, thartmann

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

  • 5189047: 8272558: IR Test Framework README misses some flags
  • ec63957: 8272398: Update DockerTestUtils.buildJdkDockerImage()
  • 14623cd: 8270835: regression after JDK-8261006
  • fe72197: 8272551: mark hotspot runtime/modules tests which ignore external VM flags
  • 05d64da: 8272291: mark hotspot runtime/logging tests which ignore external VM flags
  • a68b5b9: 8272369: java/io/File/GetXSpace.java failed with "RuntimeException: java.nio.file.NoSuchFileException: /run/user/0"
  • a199ebc: 8272581: sun/security/pkcs11/Provider/MultipleLogins.sh fails after JDK-8266182
  • 1cbf41a: 8225083: Remove Google certificate that is expiring in December 2021
  • cf64c3e: 8272326: java/util/Random/RandomTestMoments.java had two Gaussian fails
  • 2ed7b70: 8272521: Remove unused PSPromotionManager::_claimed_stack_breadth
  • ... and 2 more: https://git.openjdk.java.net/jdk/compare/0e3fde6c3c2f5c05777b79ff5eb1188014269b0f...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 Aug 17, 2021
@vnkozlov
Copy link
Contributor

On second thought, I don't get how it fixes the issue. Can you explain why it reduce false positive?
The only difference from original code is that you always run note_dep_seen(dept, x1).

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Choose a reason for hiding this comment

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

Good catch! Looks good to me.

@iwanowww
Copy link
Contributor Author

iwanowww commented Aug 18, 2021

On second thought, I don't get how it fixes the issue. Can you explain why it reduce false positive?
The only difference from original code is that you always run note_dep_seen(dept, x1).

Yes, and that's the crucial difference which fixes the problem. The bug stems from the peculiarities of note_dep_seen() implementation.

Consider the original code:

if (note_dep_seen(dept, x0) && note_dep_seen(dept, x1)) {

When a fresh assertion is added, it records only x0 because note_dep_seen(dept, x0) == false and the check fails fast.
Next time the very same assertion is made, note_dep_seen(dept, x0) == true (because note_dep_seen() recorded x0, but x1 hasn't been checked before and note_dep_seen(dept, x1) == false. So, a duplicate dependency is recorded.

Unconditionally running note_dep_seen() on x0 and x1 lets note_dep_seen() observe both arguments on the first occurrence.

Can you explain why it reduce false positive?

Checking both arguments filters out cases when second argument differs thus reducing the chances linear scan is performed.

@vnkozlov
Copy link
Contributor

Perfect! Thank you for explanation.

@iwanowww
Copy link
Contributor Author

Thanks for the reviews, Vladimir and Tobias.

/integrate

@openjdk
Copy link

openjdk bot commented Aug 18, 2021

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

  • 4d6593c: 8272124: Cgroup v1 initialization causes NullPointerException when cgroup path contains colon
  • 30b0f82: 8272626: Avoid C-style array declarations in java.*
  • e8f1219: 8271276: C2: Wrong JVM state used for receiver null check
  • 79a06df: 8272567: [IR Framework] Make AbstractInfo.getRandom() static
  • 481c1f0: 8269951: [macos] Focus not painted in JButton when setBorderPainted(false) is invoked
  • 5189047: 8272558: IR Test Framework README misses some flags
  • ec63957: 8272398: Update DockerTestUtils.buildJdkDockerImage()
  • 14623cd: 8270835: regression after JDK-8261006
  • fe72197: 8272551: mark hotspot runtime/modules tests which ignore external VM flags
  • 05d64da: 8272291: mark hotspot runtime/logging tests which ignore external VM flags
  • ... and 7 more: https://git.openjdk.java.net/jdk/compare/0e3fde6c3c2f5c05777b79ff5eb1188014269b0f...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Aug 18, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Aug 18, 2021
@openjdk
Copy link

openjdk bot commented Aug 18, 2021

@iwanowww Pushed as commit 96107e3.

💡 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
hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants