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

8270333: -XX:+VerifyStringTableAtExit should not do linear search #4772

Conversation

iklam
Copy link
Member

@iklam iklam commented Jul 14, 2021

The implementation of -XX:+VerifyStringTableAtExit used a linear search to check for duplicated strings in the interned string table. This would be excessively slow if there were more than a few thousand strings.

This PR uses a hashtable so we can avoid doing a linear search. The table is sized such that each bucket has 8 items on average.

Since this code is executed only for verification, I added a new java_lang_String::hash_code_noupdate(oop) function, so we can avoid causing side effects.


Progress

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

Issue

  • JDK-8270333: -XX:+VerifyStringTableAtExit should not do linear search

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4772

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

Using diff file

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Jul 14, 2021

👋 Welcome back iklam! 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 openjdk bot commented Jul 14, 2021

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

  • hotspot-runtime

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-runtime label Jul 14, 2021
@iklam iklam marked this pull request as ready for review Jul 14, 2021
@openjdk openjdk bot added the rfr label Jul 14, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Jul 14, 2021

Webrevs

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Changes seem fine, but I don't like your use of templates here.

Thanks,
David

template<bool update>
unsigned int java_lang_String::hash_code_impl(oop java_string) {
Copy link
Member

@dholmes-ora dholmes-ora Jul 14, 2021

Choose a reason for hiding this comment

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

This looks like a really weird way to pass a parameter! Why do we want a template here?

Copy link
Member Author

@iklam iklam Jul 14, 2021

Choose a reason for hiding this comment

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

Hi David, thanks for the review. I replaced the template function with an inline function.

@openjdk
Copy link

@openjdk openjdk bot commented Jul 14, 2021

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

8270333: -XX:+VerifyStringTableAtExit should not do linear search

Reviewed-by: dholmes, minqi

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 14 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 ready and removed ready labels Jul 14, 2021
Copy link
Member

@dholmes-ora dholmes-ora left a comment

Okay ... I'm not sure why you want the code to be duplicated though?

@iklam
Copy link
Member Author

@iklam iklam commented Jul 14, 2021

Okay ... I'm not sure why you want the code to be duplicated though?

I could add a new bool update parameter to java_lang_String::hash_code(oop java_string), but I worry about performance impacts.

It probably doesn't matter, but I just don't want to deal with any potential performance issues when changing code used only for debugging.

Copy link
Contributor

@yminqi yminqi left a comment

Looks good, but one question.

public:
size_t _errors;
VerifyCompStrings(GrowableArray<oop>* oops) : _oops(oops), _errors(0) {}
VerifyCompStrings() : _table(unsigned(_items_count + 8 / 8)), _errors(0) {}
Copy link
Contributor

@yminqi yminqi Jul 14, 2021

Choose a reason for hiding this comment

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

I guess you mean unsigned((_items_count + 8) / 8)?

Copy link
Member Author

@iklam iklam Jul 14, 2021

Choose a reason for hiding this comment

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

Thanks for the review. I changed it to _table(unsigned(_items_count / 8) + 1)

yminqi
yminqi approved these changes Jul 14, 2021
Copy link
Contributor

@yminqi yminqi left a comment

LGTM.

@iklam
Copy link
Member Author

@iklam iklam commented Jul 15, 2021

Thanks @dholmes-ora and @yminqi for the review.
/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Jul 15, 2021

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

  • 04b73bc: 8269656: The test test/langtools/tools/javac/versions/Versions.java has duplicate test cycles
  • 7c23491: 8269598: Regressions up to 5% on aarch64 seems due to JDK-8268858
  • 7d0edb5: Merge
  • 7b4d84c: 8270422: Test build/AbsPathsInImage.java fails after JDK-8259848
  • 72db09b: 8266313: (JEP-356) - RandomGenerator spec implementation requirements tightly coupled to JDK internal classes
  • 3bbd233: 8270075: SplittableRandom extends AbstractSplittableGenerator
  • 381bd62: 8266889: [macosx-aarch64] Crash with SIGBUS in MarkActivationClosure::do_code_blob during vmTestbase/nsk/jvmti/.../bi04t002 test run
  • 82c256e: 8259499: Handling type arguments from outer classes for inner class in javadoc
  • e5db9a9: 8268620: InfiniteLoopException test may fail on x86 platforms
  • 67273ae: 8269865: Async UL needs to handle ERANGE on exceeding SEM_VALUE_MAX
  • ... and 19 more: https://git.openjdk.java.net/jdk/compare/9cac94d581f240c10fe8fff2f803109a1ae30637...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Jul 15, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Jul 15, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jul 15, 2021

@iklam Pushed as commit 1ebd946.

💡 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-runtime integrated
4 participants