Java Flight Recorder and Java Mission Control on Java SE Embedded 8


Introduction


Java Mission Control (JMC)


Oracle Java Mission Control (JMC) is a set of powerful tools that can run on Oracle JDK and interact with Oracle Java SE Embedded 8 virtual machines (VMs). This set of tools deliver advanced, unobtrusive Java monitoring and management of Java SE Embedded 8 VMs, suitable for use both in development and production environments. This Web article gives an introduction to Java Mission Control, describing the main components in the tool chain, how its components differ from competing technologies, and how you can use Java Mission Control to monitor, manage, profile and diagnose your applications when running on the Java SE Embedded 8 small device platforms.

Java Flight Recorder (JFR)


The Java Flight Recorder (JFR) is an on-demand 'flight recorder' that produces detailed recordings about the Java SE Embedded 8 VM and the embedded application it is running.  Note that JFR is available with Java SE Embedded 8 Full JRE, not with the Compact Profiles.  The recorded data can be analyzed off line, using the Flight Recorder tool in Java Mission Control. The data includes an execution profile, as well as garbage collection statistics, optimization decisions, object allocation, heap statistics, and latency events for locks and I/O.

Together, JMC and JFR on a Java SE Embedded 8 platform, allows for data collection and data analysis for the first time of Java SE embedded devices, not just desktop or server computers running Oracle JDK.  Java Flight Recorder and Java Mission Control also enable remote debugging and profiling in Java SE Embedded 8 on small embedded devices.  This Web article points out the hints and tips for when specifically running on a Java SE Embedded 8 VM, so that the proper considerations are taken for an embedded environment, such as a smaller amount of dynamic memory, less powerful CPU, and smaller amount of storage space.


Java Mission Control (JMC) Tool Chain Interaction with Java SE Embedded 8


Most technologies that are being used today to monitor, manage, and profile a Java desktop or server runtime use fairly intrusive technologies, like byte code instrumentation and JVMTI.  The main focus of Java Mission Control (JMC) on a Java SE Embedded 8 device platform is to gather the data necessary with the lowest possible impact on the running system while allowing for an embedded device to be where the data is being collected.  The technology used also enables the application to run at full speed once the tool is disconnected from the Java SE Embedded VM.  This makes JMC suitable for use in production environments for embedded devices, where the impact to the runtime speed is more pronounced because of lower powered CPUs.  With the minimal overhead, JMC also minimizes the observer effect and can provide more accurate data for your embedded application than more the more common solutions.

The data flow of what happens on a development or production Java SE Embedded 8 device connecting to JMC is as follows:


 

As can be seen in Fig. 1 (above), the JMC is started on a Developer/System Administrator machine and will communicate with a JMX Agent running in a Local Java SE Embedded 8 Process on a Development or Production Java SE Embedded 8 small device.  This allows the JMX Console to interact with the Java SE Embedded 8 VM running on a small embedded device taking its measurements for later data analysis.

Java Flight Recorder (JFR) on Java SE Embedded 8


With Java Flight Recorder system administrators and developers have a new way to diagnose production issues on embedded devices running Java SE Embedded 8. JFR provides the way to collect events from a Java SE Embedded 8 application from the OS layer, the Java SE Embedded 8 VM, and all the way up to the Java SE Embedded application.  The collected events include thread latency events such as sleep, wait, lock contention, I/O, GC, and method profiling.  With the low performance impact, less than 2% for typical Java SE Embedded applications, when collecting data and events, JFR can be enabled by default and continuously collect low level data from Java applications in production environments. This will allow a much faster turnaround time for system administrators and developers when a production issue occurs. Rather than turning on data gathering after the fact, the continuously collected JFR data is simply written to disk and the analysis can be done on data collected from the application leading up to the issue, rather than data collected afterwards.

Data Analysis of Embedded Devices


Java Flight Recorder does not write events to the embedded device storage space immediately as they occur. Instead, it stores data in a hierarchy of in-memory buffers and then moves the data to the storage space when the buffers are full. Initially, the JFR runtime stores the event data in thread-local buffers, eliminating the need to synchronize between threads for every event, which greatly improves throughput.  Once a thread-local buffer has been filled, the data is transferred to a global buffer.  When this happens, synchronization is necessary between threads but, because different thread-local buffers fill up at different rates, contention is rare.  Eventually, the global buffer also runs out of space and the contents in the buffer are written to the disk. Writing to the disk is expensive and JFR ensures that it is done as efficiently possible.  The produced files are in a binary format that is extremely compact while also efficient for the applications to read and write.

You can configure JFR so that it does not write any data to the embedded device storage area.  This is the best mode when running JFR on Java SE Embedded devices since in this mode, the global buffer acts as a circular buffer and the oldest data is dropped when the buffer is full.  Even with this very low-overhead operating mode all the vital data necessary for root-cause problem analysis is still collected.  Because the most recent data is always available in the global buffer, it can be written to the storage space on demand whenever operations or surveillance systems detect a problem.  This is ideal when storage space is at a premium, such as on small device that run Java SE Embedded 8.

JMC and JFR on Java SE Embedded 8 Quick Start


To start running JMC and JFR on your Java SE Embedded 8 device, follow these links:

1. Set up JMC on your System Administrator machine running full Oracle JDK:
  http://www.oracle.com/technetwork/java/javaseproducts/mission-control/index.html

2. Set up the Java SE Embedded 8 VM using these JFR option flags:
  http://docs.oracle.com/javase/8/docs/technotes/guides/jfr/about.html#CHDHFFGE

3. Use your JMX Console to control and anlyze your Java SE Embedded 8 Process:
  http://docs.oracle.com/javase/8/docs/technotes/guides/jfr/run.html#CHDIDCHG

Summary


Java Mission Control is a versatile tools suite for monitoring, managing, diagnosing, and profiling your Java SE Embedded 8 applications running JFR. You can reliably use Java Mission Control in production embedded environments without leaving any trace in your system after it has been used, and with a much smaller performance overhead than comparable tools when it is in use, which is important when considering the resource-constrained Java SE Embedded devices.  Try it on your own Java SE Embedded 8 platform and see how it can help in your embedded development!

For more information, see these references:
http://www.oracle.com/technetwork/java/javaseproducts/mission-control/index.html
http://docs.oracle.com/javase/8/docs/technotes/guides/jfr/