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
8266642: improve ResolvedMethodTable hash function #3901
Conversation
|
/label add hotspot-runtime |
@D-D-H |
Webrevs
|
Hi,
Can you please elaborate on when there are large numbers of classes with the same name? I can see this may help that case but how likely is that case? And what is the impact on other cases as we're now increasing the overhead of the hash computation.
Thanks,
David
test/hotspot/jtreg/runtime/MemberName/ResolvedMethodTableHash.java
Outdated
Show resolved
Hide resolved
Hi David, Thanks for your comment!
Actually, the performance problem we noticed occurred in jdk 11u, here's a simplified piece of code:
Run:
This problem doesn't exist in jdk upstream because of the name-mangling mechanism for hidden class(ClassFileParser::mangle_hidden_class_name). However, if the user creates many classes with the same name by different classloaders, the performance problems will still appear, although I also think that the general user will not implement the code in this way. My plan is to fix this problem in the upstream and then backport it to JDK 11, what do you think?
I think the overhead is negligible, here is a benchmark based on ResolvedMethodTableHash.java:
on linux x86_64, result with the patch:
result without the patch:
|
Sorry, I don't have a real benchmark yet.
From JDK 11.
From my perspective, I think that this problem still exists in the mainline, but users will hardly write code that causes this problem. Since this patch will not cause obvious performance problems, I think it is harmless to add it to the main-line. |
The only way to trigger the problem without VM anonymous classes is to load the same class file by numerous class loaders and then construct But I'm not sure how much numerous class loaders themselves will stretch the JVM. It can easily make the effects of Nevertheless, IMO it still makes sense to improve the hash function.
There's the method address available ( For example, here's how
|
Hi Vladimir, Thanks for the comment. Thanks, |
test with this improvement:
test without this improvement:
|
What about the following variant?
|
@iwanowww Thanks |
Looks good to me, but, please, wait for somebody from Runtime team to approve it.
@D-D-H 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 195 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@dholmes-ora, @iwanowww, @coleenp, @stefank) but any other Committer may sponsor as well.
|
Looks good to me, with the inclusion of classLoaderData.hpp in resolvedMethodTable.hpp.
/integrate |
Mailing list message from David Holmes on hotspot-dev: On 11/05/2021 3:43 am, Denghui Dong wrote:
Is there a real benchmark that demonstrates this, rather than a
Is the output above from JDK 17 or JDK 11? It seems to show the mangled
I'm not sure it is the right approach to "fix" a problem that doesn't
Thanks for confirming. David |
1 similar comment
Mailing list message from David Holmes on hotspot-dev: On 11/05/2021 3:43 am, Denghui Dong wrote:
Is there a real benchmark that demonstrates this, rather than a
Is the output above from JDK 17 or JDK 11? It seems to show the mangled
I'm not sure it is the right approach to "fix" a problem that doesn't
Thanks for confirming. David |
Mailing list message from David Holmes on hotspot-dev: On 11/05/2021 12:37 pm, Denghui Dong wrote:
Okay but we should only be concerned about the behaviour of public defineAnonymousClass() maybe relevant for 11u, but not mainline. Thanks, |
1 similar comment
Mailing list message from David Holmes on hotspot-dev: On 11/05/2021 12:37 pm, Denghui Dong wrote:
Okay but we should only be concerned about the behaviour of public defineAnonymousClass() maybe relevant for 11u, but not mainline. Thanks, |
The identity_hash() changes look good.
FWIW, some allocators return 16 byte aligned memory chunks, so shifting by 3 might leave a non-set LSB. Maybe when fixing JDK-8267303, we should also consider if the shift should be 3 or 4.
/integrate |
Thank you! @iwanowww |
Tier1-tier2 results are good. /sponsor |
@iwanowww @D-D-H Since your change was applied there have been 224 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 83b3607. |
JDK-8249719 has fixed the bad hash function problem, however, the performance problem still exists when there are a large number of classes with the same name.
Adding the address of the corresponding ClassLoaderData as a factor of hash can solve the problem.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3901/head:pull/3901
$ git checkout pull/3901
Update a local copy of the PR:
$ git checkout pull/3901
$ git pull https://git.openjdk.java.net/jdk pull/3901/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 3901
View PR using the GUI difftool:
$ git pr show -t 3901
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3901.diff