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

8337994: [REDO] Native memory leak when not recording any events #1095

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bulasevich
Copy link

@bulasevich bulasevich commented Oct 24, 2024

(not a clean backport)
Reworked to avoid https://github.com/openjdk/jdk/pull/17328/files backport

Functional jtreg1-3 tests are Ok.
Manual testing: the reproducer shows the problem is fixed with the change (see comments below)


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
  • JDK-8337994 needs maintainer approval

Issue

  • JDK-8337994: [REDO] Native memory leak when not recording any events (Bug - P3 - Requested)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk21u-dev.git pull/1095/head:pull/1095
$ git checkout pull/1095

Update a local copy of the PR:
$ git checkout pull/1095
$ git pull https://git.openjdk.org/jdk21u-dev.git pull/1095/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1095

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk21u-dev/pull/1095.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 24, 2024

👋 Welcome back bulasevich! 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 Oct 24, 2024

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot changed the title Backport 6a9a867d645b8fe86f4ca2b04a43bf5aa8f9d487 8337994: [REDO] Native memory leak when not recording any events Oct 24, 2024
@openjdk
Copy link

openjdk bot commented Oct 24, 2024

This backport pull request has now been updated with issue from the original commit.

@openjdk openjdk bot added the backport label Oct 24, 2024
Copy link
Member

@phohensee phohensee left a comment

Choose a reason for hiding this comment

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

Just a context difference in jfrTypeSet.cpp. Lgtm.

@bulasevich bulasevich marked this pull request as ready for review October 28, 2024 18:21
@openjdk
Copy link

openjdk bot commented Oct 28, 2024

⚠️ @bulasevich This change is now ready for you to apply for maintainer approval. This can be done directly in each associated issue or by using the /approval command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 28, 2024
@mlbridge
Copy link

mlbridge bot commented Oct 28, 2024

Webrevs

@bulasevich
Copy link
Author

Reproducer:

import jdk.jfr.consumer.RecordingStream;

/**
  * Stress test to provoke the memory leak:
  * starts 1M empty threads in VM with jfr recording
  */
public class PinnedThreadTracker implements AutoCloseable
{
    private final RecordingStream recordingStream;

    public PinnedThreadTracker() {
        recordingStream = new RecordingStream();
        recordingStream.startAsync();
        System.out.println("start recording..");
    }

    @Override
    public void close() {
        recordingStream.close();
    }

    class MyThread extends Thread {
        public void run() {
        }
    }
    public void runThreads() {
        for (int i = 0; i < 100; i++) {
            for (int j = 0; j < 100; j++) {
                for (int k = 0; k < 100; k++) {
                    new MyThread().start();
                }
                MyThread thr = new MyThread(); thr.start();
                try {
                    thr.join();
                } catch (Exception ex) {}
            }
            System.out.print(".");
        }
    }

    public static void main(String a[]) {
        PinnedThreadTracker ptt = new PinnedThreadTracker();
        ptt.runThreads();
        ptt.close();
    }
}	

Manual testing results on jdk21u:

$ for i in {0..60}; do
    export PID=`ps -ax | grep java | grep PinnedThreadTracker | sed "s/^ *// ; s/ .*//"`
    jcmd $PID VM.native_memory | grep Tracing.*reserved
    sleep 1s
  done

Before the change (jcmd VM.native_memory output once a second):
-                   Tracing (reserved=17355KB, committed=17355KB)
-                   Tracing (reserved=21646KB, committed=21646KB)
-                   Tracing (reserved=25870KB, committed=25870KB)
-                   Tracing (reserved=30065KB, committed=30065KB)
...
-                   Tracing (reserved=240567KB, committed=240567KB)
-                   Tracing (reserved=244519KB, committed=244519KB)
-                   Tracing (reserved=248525KB, committed=248525KB)
-                   Tracing (reserved=252527KB, committed=252527KB)

With the fix:
-                   Tracing (reserved=17655KB, committed=17655KB)
-                   Tracing (reserved=18125KB, committed=18125KB)
-                   Tracing (reserved=18449KB, committed=18449KB)
-                   Tracing (reserved=18961KB, committed=18961KB)
...
-                   Tracing (reserved=17443KB, committed=17443KB)
-                   Tracing (reserved=17958KB, committed=17958KB)
-                   Tracing (reserved=18491KB, committed=18491KB)
-                   Tracing (reserved=18970KB, committed=18970KB)

@bulasevich
Copy link
Author

/approval request
The change fixes jfr memory leak. We need that in jdk21.

@openjdk
Copy link

openjdk bot commented Nov 4, 2024

@bulasevich
8337994: The approval request has been created successfully.

@openjdk openjdk bot added the approval label Nov 4, 2024
@GoeLin
Copy link
Member

GoeLin commented Nov 7, 2024

Hi @bulasevich, can this wait for the April update? It would get some more test coverage.

@bulasevich
Copy link
Author

Hi @bulasevich, can this wait for the April update? It would get some more test coverage.

Hi @GoeLin
In my opinion, this bug could have a significant impact on customers, and it would be ideal to fix it as soon as possible. However, I understand that some reasonable patience is necessary. I'm not opposed to waiting for the next update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval backport rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

3 participants