-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
JDK-8261334: NMT: tuning statistic shows incorrect hash distribution #2458
JDK-8261334: NMT: tuning statistic shows incorrect hash distribution #2458
Conversation
👋 Welcome back stuefe! A progress list of the required criteria for merging this PR into |
Webrevs
|
@@ -183,6 +183,9 @@ void MemTracker::final_report(outputStream* output) { | |||
if (level >= NMT_summary) { | |||
report(level == NMT_summary, output); | |||
} | |||
#ifdef ASSERT | |||
tuning_statistics(output); |
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 is irrelevant. tuning_statistics() is undocumented and should not advertise (at least, it was the decision then).
Otherwise, looks good.
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.
Okay, I remove it before pushing. Thank you.
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.
Thanks.
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 fine to me.
@tstuefe 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:
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 8 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
Since this is trivial, and all tests ran through, I'll integrate. /integrate |
@tstuefe Since your change was applied there have been 10 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 20d7713. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This is a trivial patch.
Tuning statistics for the malloc site hash map in NMT use a MallocSiteWalker to walk the malloc sites.
There is a bug in the report code which causes hash distribution statistics displayed to be (sometimes widely) off:
This is the bucket chain length histogram. Note that the sum of all values is 716 which exceeds the table width of 511, the total number of buckets.
The problem is caused by a bug in the walker code where the bucket index is calculated by manually mod'ing
NativeCallStack::hash()
with table size:jdk/src/hotspot/share/services/memTracker.cpp
Line 263 in d0a8f2f
which is wrong since the hash is defined as signed int. So it yields incorrect index values if the hash code is <0, compared with the regular hashcode-to-index calculation done in the table itself, which translates the hash into an unsigned value before mod'ing:
jdk/src/hotspot/share/services/mallocSiteTable.hpp
Line 243 in d0a8f2f
This is an old bug introduced with JDK-8046598 in 2014. Note that it causes the statistics to look better than it actually is, since it reports a long chain as multiple short chains.
The patch is really minimal, just adding the necessary cast at the right place. Patch is small for easy backporting. Hash code calculation will be touched up as part of https://bugs.openjdk.java.net/browse/JDK-8261302, so I'd like to keep the patch minimal. I also added tracing code to print tuning info as part of the final NMT report in debug VMs.
This is the correct output after the patch. Sum of buckets is 511 as expected. Note that the statistics are way less flattering now, since there are really almost none 1-length chains as the broken statistic claims:
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/2458/head:pull/2458
$ git checkout pull/2458