Running the sample application using AOT

This procedure runs a standard Java™ application in a real-time environment using the ahead-of-time (AOT) compiler, without the need to rewrite code. Use this sample to compare running the same application using the JIT compiler.

Before you begin

To run the sample application, you must first build the sample source code. See Building the sample application for more information.

About this task

The ahead-of-time compiler compiles your Java application to native code before running it. Therefore, you can predict how the application runs more precisely, because there are no interruptions caused by just-in-time (JIT) compilation.
Procedure
  1. Convert the application bytecodes into native code.
    1. Identify which bytecodes to precompile by running the sample with the normal JIT compiler:
      java -Xrealtime -Xjit:verbose={precompile},vlog=./sim.aotOpts \
           -classpath ./demo.jar -Xgc:scopedMemoryMaximumSize=11m demo.sim.SimLauncher <port>
      And in a new window, enter:
      java -Xrealtime -Xjit:verbose={precompile},vlog=./control.aotOpts \
           -classpath ./demo.jar -Xmx300m demo.controller.JavaControlLauncher localhost <port>
      where <port> is an deallocated port for this workstation. You will see messages similar to the following:
      Fire down transitions 141, fire horizontally transitions 141
      and:
      Land!
    2. Combine the AOT options files. The names used for the log files created in the previous step have date and process ID information appended to the file name specified by the vlog= option. For example, vlog=sim.aotOpts generates a file name similar to sim.aotOpts.20081014.234958.13205:
      cat sim.aotOpts.20081014.234958.13205 control.aotOpts.20081014.234958.13205 > sample.aotOpts
  2. Start the simulation: where <port> is an unallocated port for this workstation.
  3. Start the controller: where <host> is the hostname of the workstation running the simulation and <port> is the port specified in the previous step. Running both JVMs on the same workstation can lead to less deterministic behavior. See Considerations for more information.

Results

As with the non-real-time example, the application now runs and generates data points and a graph.

In this run with ahead-of-time compilation, the graph shows no spikes in the blue Radar Height, and very accurate tracking of the red Real Height line, because the Controller code is now running with only very short garbage collection pauses and no just-in-time compilation interruptions.

Figure 1. Graph generated by the sample application with ahead-of-time compilation
Graph shows blue line tracking consistently close to red line.


© Copyright IBM Corporation 2005, 2010. All Rights Reserved.
© Copyright Sun Microsystems, Inc. 1997, 2007, 901 San Antonio Rd., Palo Alto, CA 94303 USA. All rights reserved.
US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
This information center is powered by Eclipse technology. (http://www.eclipse.org/)