X
  • November 14, 2017

Clarifying some confusion around Java Flight Recordings

Poonam Parhar
Consulting Member of Technical Staff

In this blog, I am going to talk about two confusions around Java Flight Recordings that I have come across from multiple users/customers. Let's take a look at them one by one.

Flight Recordings Interval

A number of Java Flight Recorder users seem to have a confusion around the 'start-time' and the 'interval' of the flight recordings. The complaint is that the flight recordings in the Java Mission Control show longer recording interval than their actual recorded data. For example, the following screenshot shows that the flight recording has the interval of 5 hours and 35 minutes but the actual recording data in it is only for 59 minutes.

This might seem like a bug, and you might question as to why the flight recording is having timeline with no obvious recorded events in it.

Well, this isn’t a bug. If we go to the Events->Log tab and sort the events with their ‘Start Time’, we can see an Event ‘Java Thread Park’ that had started at 1:37:28 PM.

This event had started before the actual start-time of the recording. The JMC chose to include this event, and to accommodate this event it ended up showing interval of the recording which is much longer than the actual duration of the recording.  So, whenever we see part of the recording timeline not having any data in it, it is worth checking the events log to see if there are any events that had started before we had actually started that flight recording.

JFR Repository and Destination

Another confusion I often hear is around the use of the JFR Repository and the destination for recordings. One such question:

“I have configured maxsize for my recordings but the recordings I see created in my JFR repository are much smaller than my specified maxsize. Why is that so?”

Well, JFR repository is not the destination folder for the recordings. JFR repository is used internally by the Flight Recorder to store chunks of JFR data when the thread/global JFR buffers are flushed out to the disk. ‘maxage’ and ‘maxsize’ settings are honored for the collective size of chunk files that are kept in the Repository folder and the individual chunk files can be smaller than the specified maximum 'maxsize' i.e. the total size of all the chunks created in the repository folder should not go beyond the limit set with the ‘maxsize’ option. The older chunk files exceeding the maxsize/maxage limit are deleted by the Flight Recorder.

Let’s consider this example, where I start a java process with the FlightRecorder enabled, and then start a flight recording in it with ‘maxsize’ limit as 2mb.

D:\tests>jcmd 30824 JFR.start name=recording1 maxsize=2mb
30824:
Started recording 1.
Use JFR.dump name=recording1 filename=FILEPATH to copy recording data to file.

D:\tests>jcmd 30824 JFR.check
30824:
Recording: recording=1 name="recording1" maxsize=2.0MB (running)

Now, every time I dump the running recording, it is written to the disk either in the specified destination folder or in the current working folder if ‘destination’ is not specified.

D:\tests>jcmd 30824 JFR.dump recording=1 filename=1.jfr
30824:
Dumped recording 1, 1.8 MB written to:
D:\tests\1.jfr

D:\tests>jcmd 30824 JFR.dump recording=1 filename=1.jfr
30824:
Dumped recording 1, 2.0 MB written to:
D:\tests\1.jfr

And each time the recording is dumped, before it is written to the destination folder, data in the JFR buffers is flushed out in the form of chunk files to the JFR repository. At this point, the Flight Recorder checks for the limits configured for the recording (maxsize in this case) and removes the older chunk files to ensure that the specified limits are honored. For example, in this case, every time a new chunk file is written into the repository, the Flight Recorder deletes old chunk files to ensure that the total size of all the files in the repository does not exceed 2MB.

 

Now, when I dump again, the older files in the repository are removed to keep the total size of all the chunk files up to 2mb as shown in the following image.

D:\tests>jcmd 30824 JFR.dump recording=1 filename=1.jfr
30824:
Dumped recording 1, 2.0 MB written to:
D:\tests\1.jfr

 

That's all for this post!

 

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha

Recent Content

Oracle

Integrated Cloud Applications & Platform Services