JDK Mission Control

266 views Asked by At

enter image description hereWhen opening the tab of memory in jdk mission control with jfr file, it's getting nothing. İs there any parameters to setting the process which is I get jfr file. I've just added that parameter to enable flight recorder.

java -XX:+UnlockCommercialFeatures -XX:+FlightRecorder ... myapp
2

There are 2 answers

1
Mario.Cadiz On

The params of events gathered by the JFR are controlled the JFC files. The JDK is packed with 2 of them:

$JAVA_HOME/lib/jfr/default.jfc
$JAVA_HOME/lib/jfr/profile.jfc

The default.jfc will collect less events than the profile.jfc file.

Verify which of them is used when your Java process is launched. That's regarding the JFC file.

Now, there are 2 ways to start up a JFR file, continuous recording and profiling recording, that will depend on what you are using in the JVM options.

Continuous Recording

When to use it? The issue is intermittent, recording a JFR continuously is required until the issue is replicated. At that moment, dump the recording into a JFR file.

A temporary repository can be configured where temporary JFR files will be created. By default, it's located at the /tmp folder or java.io.tmpdir system property. Don't process the JFR files under the temporary repository, those are just temporary files, they are incomplete.

About disk=[true|false] Specifies whether to write temporary data to the disk repository. By default, this parameter is set to false. To enable it, set the parameter to true. (star)

Once the issue is replicated it, use the JFR.dump command to create the JFR file. At that point, when you already have the desired evidence, the JFR can be stopped with JFR.stop.

-XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:FlightRecorderOptions=defaultrecording=true,disk=true,repository=<PATH>

An alternative to dump the file once the process exits:

-XX:FlightRecorderOptions=defaultrecording=true,dumponexit=true,dumponexitpath=<PATH>

Set path to the location where the recording should be saved. If you specify a directory, a file with the date and time as the name is created in that directory. If you specify a file name, that name is used. If you do not specify a path, the recording will be saved in the current directory.

Example of the sequence of command for continuous recording:

JFR.start name=myrecording maxage=30m settings=[TEMPLATE].jfc

JFR.check (optional)

JFR.dump

JFR.stop

Profiling Recording

The issue is consistent. How to replicate it or when it's going to occur is known, hence you need a period of time to collect a JFR when you are sure the issue will be replicated at least once.

-XX:+UnlockCommercialFeatures -XX:+FlightRecorder

Example of a sequence of commands for profiling recording:

JFR.start name=myrecording filename=myrecording.jfr duration=10m settings=[TEMPLATE].jfc

JFR.check (optional)

JFR.stop (optional)

At this point, the questions are:

  1. Which recording mode fits better with your issue?
  2. Are you using the right JVM options for the recording mode?
  3. Which JFC file are you using?
  4. Are you executing the sequence of JFR commands corresponding with the recording mode?
0
Kire Haglin On

The missing data could be because the TLAB events were disabled when jdk.ObjectAllocationSample event was introduced. See JDK 16 release notes. The new event has less overhead and can always be enabled.

You need to upgrade JMC to a release where the new event is visualized, not sure if has been implemented yet, or you can enable the old events on command-line (works for JDK 17, or later)

$ java -XX:StartFlightRecording:
    jdk.ObjectAllocationInNewTLAB#enabled=true,
    jdk.ObjectAllocationOutsideTLAB#enabled=true
    myapp