Search code examples
javajvmmethod-calljfr

Are the call-stacks from a RecordedFile in JFR complete?


For the duration of a recording using Java Flight Recorder, will all the methods that are called within that duration be listed in a RecordedFile?

Given that:

  • I am not recording a subset of events.
  • I have not created any custom events.
  • I am using AdoptOpenJDK 11.0.10

Thanks in advance for any answers.


Solution

  • No.

    First, JFR is a sampling profiler. It does not record all method transitions; it takes periodic samples instead. I.e. once in the specified time interval, it looks at the call stacks of the threads running at the moment.

    Second, JFR tends to miss many samples when it fails to traverse a valid Java stack. I demonstrated this effect in my presentation: JFR caught just one meaningless application stack trace out of 10 seconds of execution.

    You can choose how many samples JFR collects by tuning the sampling period setting. The smaller is period - the more stack samples JFR collects. However, the smallest possible period is just 1 ms. Furthermore, the sampling frequency does not scale well with the number of running threads. There is just one thread that collects all ExecutionSample events, no matter how many cores your server has.