Skip to content

8343893: Test jdk/jfr/event/runtime/TestNativeMemoryUsageEvents.java failed: heap should have grown and NMT should show that: expected 0 > 0 #22204

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 6 commits into from

Conversation

jdksjolen
Copy link
Contributor

@jdksjolen jdksjolen commented Nov 18, 2024

Background

With the implementation of JDK-8312132 we added the MemoryFileTracker (MFT). Unfortunately, this work failed to implement JFR integration. This, in turn, meant that (generational) ZGC has not correctly reported its heap usage via the NMT JFR events. We (as in Oracle) never saw this issue in testing, as we didn't run this test for all possible GC configurations. With an update of our test configurations this is no longer the case: We run this test for all possible GCs and the test now fails for generational ZGC.

The fix

I implemented JFR events for the MFT by adding all of its reserved and committed memory into the JFR data, similarly to the VirtualMemoryTracker. I also added an explicit run using ZGC to the failing test, to ensure that any actual regressions are found.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8343893: Test jdk/jfr/event/runtime/TestNativeMemoryUsageEvents.java failed: heap should have grown and NMT should show that: expected 0 > 0 (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22204/head:pull/22204
$ git checkout pull/22204

Update a local copy of the PR:
$ git checkout pull/22204
$ git pull https://git.openjdk.org/jdk.git pull/22204/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22204

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22204.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 18, 2024

👋 Welcome back jsjolen! 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 Nov 18, 2024

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

8343893: Test jdk/jfr/event/runtime/TestNativeMemoryUsageEvents.java failed: heap should have grown and NMT should show that: expected 0 > 0

Reviewed-by: gziemski, mgronlun, lmesnik

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 99 new commits pushed to the master branch:

  • 882d635: 8245545: Disable TLS_RSA cipher suites
  • 8f22db2: 8330606: Redefinition doesn't but should verify the new klass
  • a62279c: 8344235: Revisit SecurityManager usage in java.logging after JEP 486 and JEP 491 integration
  • 18df6fd: 8336707: Contention of ForkJoinPool grows when stealing works
  • f2b10c6: 8340422: ZGC: TestAllocateHeapAt.java should not run with transparent hugepages
  • 5ccd510: 8326369: Add test to verify bimorphic inlining happens after morphism changes
  • 93aa7e2: 8328085: C2: Use after free in PhaseChaitin::Register_Allocate()
  • 10def48: 8344236: Revisit SecurityManager usage in jdk.net after JEP 486 integration
  • 7105bb9: 8344664: Remove some un-used java/sun.security imports in the java.desktop module
  • a01aa22: 8342281: Deprecate for removal javax.sound.sampled.AudioPermission
  • ... and 89 more: https://git.openjdk.org/jdk/compare/5eb0733f5f4652751214dac5af51c1812e0925e6...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 changed the title 8343893 8343893: Test jdk/jfr/event/runtime/TestNativeMemoryUsageEvents.java failed: heap should have grown and NMT should show that: expected 0 > 0 Nov 18, 2024
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 18, 2024
@openjdk
Copy link

openjdk bot commented Nov 18, 2024

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

  • hotspot-jfr

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-jfr hotspot-jfr-dev@openjdk.org label Nov 18, 2024
@mlbridge
Copy link

mlbridge bot commented Nov 18, 2024

Webrevs

@jdksjolen
Copy link
Contributor Author

/label hotspot-runtime

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Nov 18, 2024
@openjdk
Copy link

openjdk bot commented Nov 18, 2024

@jdksjolen
The hotspot-runtime label was successfully added.

Copy link

@mgronlun mgronlun left a comment

Choose a reason for hiding this comment

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

Looks good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 18, 2024
@jdksjolen
Copy link
Contributor Author

Leonid convinced me that it's unnecessary to have the ZGC case for the test, so I removed it.

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed ready Pull request is ready to be integrated labels Nov 18, 2024
Copy link

@gerard-ziemski gerard-ziemski left a comment

Choose a reason for hiding this comment

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

Just and observation - you used here the acronym MFT and it just jumped out at me, then I looked at memoryFileTracker and it feels inconsistent to me.

Did we ever consider naming it nativeMemoryFileTracker? Then we would have NMFT, which extends NMT better, IMHO.

Just something to keep in mind if we ever feel like cleaning up the names in NMT area.

Comment on lines 94 to 105

{ // MemoryFileTracker addition
using MFT = MemoryFileTracker::Instance;
MFT::Locker lock;
MFT::iterate_summary([&](MemTag tag, const VirtualMemory* vm) {
int i = NMTUtil::tag_to_index(tag);
_vm_by_type[i].reserved += vm->reserved();
_vm_by_type[i].committed += vm->committed();
_vm_total.reserved += vm->reserved();
_vm_total.committed += vm->committed();
});
}
Copy link

@gerard-ziemski gerard-ziemski Nov 19, 2024

Choose a reason for hiding this comment

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

I am missing something here, in memoryFileTracker.hpp you say:

// All memory is accounted as committed, there is no reserved memory.
// Any reserved memory is expected to exist in the VirtualMemoryTracker.

but here we use MFT to account for both reserved and committed?

Choose a reason for hiding this comment

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

Ah, we actually do use VirtualMemory here to track the memory. Never mind!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, but it is actually 0 :). I wanted to future proof this code, if we ever do use reserved here. I'll assert that reserved is 0 with a good message, then we can fix the code if our assumptions change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I was pretty confused here. We need to remove the reserved additions, otherwise we double-account reserved memory.

Copy link

@gerard-ziemski gerard-ziemski left a comment

Choose a reason for hiding this comment

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

LGTM

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Nov 21, 2024
Copy link

@gerard-ziemski gerard-ziemski left a comment

Choose a reason for hiding this comment

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

That matches the comments from src/hotspot/share/nmt/memoryFileTracker.hpp

I've seen the issue of overcounting pop-up couple of times recently - can we write a test that checks and would have caught the issue we ran into just here?

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 21, 2024
@jdksjolen
Copy link
Contributor Author

Cheers Gerard. I'm not entirely sure of how to write a test for catching this, if you have any ideas that'd be great.

/integrate

@openjdk
Copy link

openjdk bot commented Nov 22, 2024

Going to push as commit 2ea0364.
Since your change was applied there have been 121 commits pushed to the master branch:

  • 50c099d: 8344799: Remove permissions checks from java.awt.Desktop
  • e21d06f: 8344338: javax/swing/JTextArea/bug4265784.java fails on Ubuntu 24.04.1
  • db44e97: 8344798: Shenandoah: Use more descriptive variable names in shPhaseTimings.cpp
  • c199f53: 8344336: SM cleanup of java.lang.System, Runtime, String, StackWalker
  • 0f458e2: 8342903: Deprecate for removal java.awt.Window.getWarningString()
  • efeacfe: 8344646: The libjsig deprecation warning should go to stderr not stdout
  • 2214906: 8272339: Update notes section from serialver man page
  • cee74f9: 8338536: Permanently disable remote code downloading in JNDI
  • 7709d43: 8344782: Cleanup left over doPrivileged calls and imports in java.desktop
  • e03b150: 8178966: Don't swallow early bootstrap exceptions in Boolean.getBoolean, Integer.getInteger and Long.getLong
  • ... and 111 more: https://git.openjdk.org/jdk/compare/5eb0733f5f4652751214dac5af51c1812e0925e6...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 22, 2024
@openjdk openjdk bot closed this Nov 22, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 22, 2024
@openjdk
Copy link

openjdk bot commented Nov 22, 2024

@jdksjolen Pushed as commit 2ea0364.

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

Successfully merging this pull request may close these issues.

4 participants