Understanding the following considerations can help you improve the performance of your Java™ applications.
To greatly improve the startup performance of your Java code, use the Create Java Program (CRTJVAPGM) control language command before running Java class files, JAR files, or ZIP files. The CRTJVAPGM command uses the bytecodes to create a Java program object, which contains optimized native instructions for the iSeries™ server, and associates the Java program object with the class file, JAR file, or ZIP file.
Subsequent runs are much faster because the Java program is saved and remains associated with the class file or JAR file. Running the bytecodes interpretively may provide acceptable performance during application development, but you may want to use the CRTJVAPGM command before running the Java code in a production environment.
When you do not use CRTJVAPGM before running a Java class file, JAR file, or ZIP file, i5/OS™ uses the Just-In-Time compiler (with the Mixed-Mode Interpreter) instead.
Selecting the optimization level
When creating your Java program object, use the following guidelines to help you select the best optimization level for the run mode that you want to use:
For more information, see the following pages:
Using the Just-In-Time (JIT) compiler with the Mixed-Mode Interpreter (MMI) results in startup performance that almost equals that of compiled code. MMI interprets your Java code until reaching the threshold specified by the os400.jit.mmi.threshold Java system property. After reaching the threshold, i5/OS spends the time and resources required to use the JIT compiler to compile a method on the most frequently used methods. Using the JIT compiler results in highly optimized code that improves runtime performance when compared to precompiled code. When you require improved startup performance with the JIT compiler, you can use CRTJVAPGM to create an optimized Java program object.
If your program is running slowly, enter the Display Java Program (DSPJVAPGM) control language command to view the attributes of a Java program object. Make sure that the Java program object uses the best run mode for your purposes. If you want to change the run mode, you may want to delete the Java program object and create a new one using different optimization parameters.
For more information, see the following:
Using the i5/OS Java virtual machine (JVM) cache for user class loaders improves startup performance for classes that you load from a user class loader. The cache stores the optimized Java program objects, which enables the JVM to reuse them. Reusing stored Java programs improves performance by avoiding both recreating the cached Java program objects and verifying the bytecode.
Use the following properties to control caches for user class loaders:
Use DSPJVAPGM on the JAR file, which you specify in the os400.define.class.cache.file property, to determine the number of cached Java program objects.
Cache performance
Running some Java applications can cache a large number of Java program objects. Use DSPJVAPGM to determine if the number of cached Java programs approaches the maximum value before the application finishes running. Application performance can degrade when the cache gets full because i5/OS may remove from the cache some programs that the application requires.
You can prevent performance degradation that results when the cache becomes full. For example, you can set up applications to use separate caches for applications that run frequently but load different programs into the cache. Using separate caches can prevent the cache from getting full and thus prevent i5/OS from removing Java programs from the cache. Alternatively, you can increase the number that you specify for the os400.define.class.cache.maxpgms property.
You can use Change Java Program (CHGJVAPGM) control language command on the JAR file to change the optimization of the classes in the cache. CHGJVAPGM affects only programs that the cache currently holds. After you make changes to the optimization levels, the os400.defineClass.optLevel property specifies how to optimize any classes that are added to the cache.
For example, to use the shipped cache JAR with a maximum of 10000 Java program objects, where each Java program has a maximum life of 1 year, set the following values for the cache properties:
os400.define.class.cache.file /QIBM/ProdData/Java400/QDefineClassCache.jar os400.define.class.cache.hours 8760 os400.define.class.cache.maxpgms 10000