简体   繁体   中英

Java Flight Recorder not reporting all GC events

We have performance build that spawns up our application with the following flags turned on:

-XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:FlightRecorderOptions=dumponexit=true,dumponexitpath=/tmp/ImaginaryApplication/logs/flightRecorder.jfr -XX:StartFlightRecording=defaultrecording=true,settings=MyCustomSetting

The custom setting was created through Flight Recorder UI, with all settings turned on. I guess the important section that is relevant to my question here is the following:

  <selection name="gc-level" default="all" label="Garbage Collector">
    <option label="Off" name="off">off</option>
    <option label="Normal" name="detailed">normal</option>
    <option label="All" name="all">all</option>
  </selection>

  <condition name="gc-enabled-normal" true="true" false="false">
    <or>
      <test name="gc-level" operator="equal" value="normal"/>
      <test name="gc-level" operator="equal" value="all"/>
    </or>
  </condition>

  <condition name="gc-enabled-all" true="true" false="false">
    <test name="gc-level" operator="equal" value="all"/>
  </condition>

The flight recording was generated when the build stops. However, I am not 100% confident that it records everything. For a start, only few GC was reported within the Memory -> Garbage Collection page. I know this, because we also turned on the flag to write the GC into file. There is way more GC than what was reported in the flight recorder. More importantly, I am worried that the memory allocation result did not record accurate information (just like the GC events). In which case, we might have spent a lot of effort in tuning the wrong areas..

Have I missed any setting here?

Thank you in advance!

I use settings=profile as the default settings doesn't record all allocation information.

Even then it only records the object which triggers a new TLAB which can be large by default. To increase the number samples I shrink the TLAB with -XX:TLABSize=128k NOTE this can hurt performance a little so I wouldnt use except for profiling.

By default all garbage collection events are not enabled. By that I mean, the main GC events are there, so you can see pause times etc., but not all the gritty details.

The easiest way to enable all GC events is to use Java Mission Control and the Recording Wizard to export a configuration. Select "All" in the drop down for "Garbage Collection".

If you can't connect to the JVM using JMC, you can use the Flight Recorder Template Manager in JMC, located in the Window menu. You can import the default.jfc located in JDK_HOME/bin/lib/jfr directory, duplicate it and edit it. Select "All" for Garbage Collection and export the configuration to a new file.

You can then start the JVM with:

java -XX:StartFlightRecording:settings=all-gc-events.jfc

The settings shown in your question are not read by the JVM. They are only used by JMC to apply settings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM