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

8334026: Provide a diagnostic PrintMemoryMapAtExit switch on Linux #19660

Conversation

tstuefe
Copy link
Member

@tstuefe tstuefe commented Jun 11, 2024

To investigate footprint problems of processes with a short lifespan (e.g. startup footprint problems), we found it very useful to be able to get an annotated memory map at exit - the same map printed by jcmd System.map.


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-8334026: Provide a diagnostic PrintMemoryMapAtExit switch on Linux (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19660

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 11, 2024

👋 Welcome back stuefe! 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 Jun 11, 2024

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

8334026: Provide a diagnostic PrintMemoryMapAtExit switch on Linux

Reviewed-by: dholmes, mbaesken

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

  • d7dad50: 8334544: C2: wrong control assigned in PhaseIdealLoop::clone_assertion_predicate_for_unswitched_loops()
  • ff30240: 8334239: Introduce macro for ubsan method/function exclusions
  • 2d4185f: 8332717: ZGC: Division by zero in heuristics
  • fad6644: 8333754: Add a Test against ECDSA and ECDH NIST Test vector
  • b211929: 8334570: Problem list gc/TestAlwaysPreTouchBehavior.java
  • 4e58d8c: 8309821: Link to hidden classes section in Class specification for Class::isHidden
  • 78682fe: 8329288: Update Visual Studio visibility support for POSIX functions
  • bcf4bb4: 8333344: JMX attaching of Subject does not work when security manager not allowed
  • 856931d: 8304732: jdk/jfr/api/consumer/recordingstream/TestStop.java failed again with "Expected outer stream to have 3 events"
  • 01ee424: 8294960: Convert java.base/java.lang.invoke package to use the Classfile API to generate lambdas and method handles
  • ... and 81 more: https://git.openjdk.org/jdk/compare/aaaa86b57172d45d1126c50efc270c6e49aba7a5...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 JDK-8334026: Provide a diagnostic PrintMemoryMapAtExit switch on Linux 8334026: Provide a diagnostic PrintMemoryMapAtExit switch on Linux Jun 11, 2024
@openjdk
Copy link

openjdk bot commented Jun 11, 2024

@tstuefe 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 hotspot-runtime-dev@openjdk.org label Jun 11, 2024
@tstuefe tstuefe marked this pull request as ready for review June 12, 2024 07:06
@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 12, 2024
@mlbridge
Copy link

mlbridge bot commented Jun 12, 2024

Webrevs

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Seems quite reasonable. One query and a couple of minor nits.

Thanks

Comment on lines 41 to 43
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
"-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintMemoryMapAtExit",
"-XX:NativeMemoryTracking=summary", "-version");
Copy link
Member

Choose a reason for hiding this comment

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

Nit: indentation is off here.

Comment on lines +46 to +48
output.shouldContain("Memory mappings");
output.shouldContain("JAVAHEAP");
output.shouldHaveExitValue(0);
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: check the exit value first. If we crashed then the other checks will likely fail before we get here.

@@ -203,6 +204,8 @@ static void print_thread_details(uintx thread_id, const char* name, outputStream
// Given a region [from, to), if it intersects a known thread stack, print detail infos about that thread.
static void print_thread_details_for_supposed_stack_address(const void* from, const void* to, outputStream* st) {

ResourceMark rm;
Copy link
Member

Choose a reason for hiding this comment

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

Why was this needed to be added here? Shouldn't callers have any needed ResourceMarks?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is needed because in this function we call Thread::name() which for java threads returns an RA-allocated string. This issue popped up now because we are called without a ResourceMark at VM exit. I have not investigated closer since I think the Resourcemark makes sense here: The function does not export any RA-allocated memory but may be called in a loop many times.

Copy link
Member

Choose a reason for hiding this comment

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

Okay. I was trying to find where the existing callers have their RM and it is not obvious.

Copy link
Member Author

@tstuefe tstuefe Jun 20, 2024

Choose a reason for hiding this comment

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

Existing caller is DCmd::parse_and_execute, where we have an RM that guards every individual Dcmd execution. So, this had been a small leak of sorts, since we accumulate thread names for all java threads printed.

@tstuefe
Copy link
Member Author

tstuefe commented Jun 18, 2024

Thanks @dholmes-ora !

I worked in your remarks.

Copy link
Member

@dholmes-ora dholmes-ora 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. Thanks

@@ -203,6 +204,8 @@ static void print_thread_details(uintx thread_id, const char* name, outputStream
// Given a region [from, to), if it intersects a known thread stack, print detail infos about that thread.
static void print_thread_details_for_supposed_stack_address(const void* from, const void* to, outputStream* st) {

ResourceMark rm;
Copy link
Member

Choose a reason for hiding this comment

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

Okay. I was trying to find where the existing callers have their RM and it is not obvious.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 18, 2024
@tstuefe
Copy link
Member Author

tstuefe commented Jun 20, 2024

Thanks @MBaesken and @dholmes-ora !

/integrate

@openjdk
Copy link

openjdk bot commented Jun 20, 2024

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

  • cabd104: 8334164: The fix for JDK-8322811 should use _filename.is_set() rather than strcmp()
  • d7dad50: 8334544: C2: wrong control assigned in PhaseIdealLoop::clone_assertion_predicate_for_unswitched_loops()
  • ff30240: 8334239: Introduce macro for ubsan method/function exclusions
  • 2d4185f: 8332717: ZGC: Division by zero in heuristics
  • fad6644: 8333754: Add a Test against ECDSA and ECDH NIST Test vector
  • b211929: 8334570: Problem list gc/TestAlwaysPreTouchBehavior.java
  • 4e58d8c: 8309821: Link to hidden classes section in Class specification for Class::isHidden
  • 78682fe: 8329288: Update Visual Studio visibility support for POSIX functions
  • bcf4bb4: 8333344: JMX attaching of Subject does not work when security manager not allowed
  • 856931d: 8304732: jdk/jfr/api/consumer/recordingstream/TestStop.java failed again with "Expected outer stream to have 3 events"
  • ... and 82 more: https://git.openjdk.org/jdk/compare/aaaa86b57172d45d1126c50efc270c6e49aba7a5...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jun 20, 2024

@tstuefe Pushed as commit c6f3bf4.

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

Successfully merging this pull request may close these issues.

3 participants