ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaha_5.4.0.1/runtperf.htm

224 lines
15 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="concept" />
<meta name="DC.Title" content="Java performance considerations" />
<meta name="abstract" content="Understanding the following considerations can help you improve the performance of your Java applications." />
<meta name="description" content="Understanding the following considerations can help you improve the performance of your Java applications." />
<meta name="DC.Relation" scheme="URI" content="tuning.htm" />
<meta name="DC.Relation" scheme="URI" content="evenperf.htm" />
<meta name="DC.Relation" scheme="URI" content="gc.htm" />
<meta name="DC.Relation" scheme="URI" content="jnmiperf.htm" />
<meta name="DC.Relation" scheme="URI" content="jmiperf.htm" />
<meta name="DC.Relation" scheme="URI" content="excperf.htm" />
<meta name="DC.Relation" scheme="URI" content="callperf.htm" />
<meta name="DC.Relation" scheme="URI" content="profperf.htm" />
<meta name="DC.Relation" scheme="URI" content="colpdc.htm" />
<meta name="DC.Relation" scheme="URI" content="selmod.htm" />
<meta name="DC.Relation" scheme="URI" content="interprt.htm" />
<meta name="DC.Relation" scheme="URI" content="transfor.htm" />
<meta name="DC.Relation" scheme="URI" content="jit.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="runtperf" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title> Java performance considerations</title>
</head>
<body id="runtperf"><a name="runtperf"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1"> Java performance considerations</h1>
<div><p>Understanding the following considerations can help you improve
the performance of your Java™ applications.</p>
<div class="section"><h4 class="sectiontitle">Creating optimized Java programs</h4><p>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.</p>
<p>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.</p>
<p>When you do not use CRTJVAPGM before running
a Java class
file, JAR file, or ZIP file, <span class="keyword">i5/OS™</span> uses
the Just-In-Time compiler (with the Mixed-Mode Interpreter) instead.</p>
<p><strong>Selecting
the optimization level</strong></p>
<p>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:</p>
<ul><li>When you want to use direct processing, create the optimized Java program
object at optimization level 30 or 40.</li>
<li>When you want to run only with the JIT compiler, create the optimized Java program
by using the <kbd class="userinput">*Interpret</kbd> optimization parameter. A Java program
created by using the <kbd class="userinput">*Interpret</kbd> parameter is smaller
than one created by using optimization level 40.</li>
<li>When you want to use the default run mode, which is a mix of direct processing
and the JIT compiler, use the following settings to create your Java program
objects: <ul><li>For classes that you want to run with direct processing, use either optimization
level 30 or 40</li>
<li>For classes that you want to run with the JIT compiler, use the <kbd class="userinput">*Interpret</kbd>
optimization parameter</li>
</ul>
</li>
</ul>
<p>For more information, see the following pages:</p>
<p><a href="../cl/crtjvapgm.htm" target="_blank">Create Java Program
(CRTJVAPGM) control language command</a></p>
<p><a href="selmod.htm">Select
which mode to use when running a Java program</a></p>
</div>
<div class="section"><h4 class="sectiontitle">Using the Just-In-Time compiler</h4><p> 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, <span class="keyword">i5/OS</span> 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.</p>
<p>If your program
is running slowly, enter the <a href="../cl/dspjvapgm.htm" target="_blank">Display Java Program (DSPJVAPGM)</a> 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.</p>
<p>For more information, see the
following:</p>
<blockquote> <p><a href="../cl/dspjvapgm.htm" target="_blank">Display Java Program
(DSPJVAPGM) Control Language command</a></p>
</blockquote>
</div>
<div class="section"><h4 class="sectiontitle">Using caches for user class loaders</h4><p>Using the <span class="keyword">i5/OS</span> 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.</p>
<p> Use the following properties to
control caches for user class loaders: </p>
<dl><dt class="dlterm">os400.define.class.cache.file</dt>
<dd> The value of this property specifies the name (with the full path) of
a valid Java ARchive (JAR) file. At a minimum, the specified
JAR file must contain a valid JAR directory (as built by the <samp class="codeph">jar</samp> QSH
command) and the single member required for the <samp class="codeph">jar</samp> command
to function. Do not include the specified JAR file in any Java CLASSPATH.
The default value of this property is /QIBM/ProdData/Java400/QDefineClassCache.jar.
To disable caching, specify this property with no value.</dd>
<dt class="dlterm">os400.define.class.cache.hours</dt>
<dd> The value of this property specifies how long (in hours) that you want
a Java program
object to persist in the cache. When the JVM does not use a cached Java program
object by the specified length of time, <span class="keyword">i5/OS</span> removes
the Java program
object from the cache. The default value of this property is 768 hours (33
days). The maximum value is 9999 (about 59 weeks). When you specify either
a value of 0 or a value that <span class="keyword">i5/OS</span> does
not recognize as a valid decimal number, <span class="keyword">i5/OS</span> uses
the default value.</dd>
<dt class="dlterm">os400.define.class.cache.maxpgms</dt>
<dd> The value of this property specifies the maximum number of Java program
objects that the cache can hold. When the cache exceeds this limit, <span class="keyword">i5/OS</span> removes the oldest Java program
object from the cache. <span class="keyword">i5/OS</span> determines
which cached program is oldest by comparing times when the JVM last referenced
the Java program
objects. The default value is 5000, and the maximum value is 40000. When
you specify either a value of 0 or a value that <span class="keyword">i5/OS</span> does
not recognize as a valid decimal number, <span class="keyword">i5/OS</span> uses
the default value.</dd>
</dl>
<p>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.</p>
<ul><li>The <strong>Java programs</strong> field of the DSPJVAPGM display indicates
the number of cached Java program objects.</li>
<li>The <strong>Java program size</strong> field indicates the amount of
storage used by the cached Java program objects.</li>
<li>Other fields of the DSPJVAPGM display are meaningless when you use the
command on a JAR file that you are using for caching.</li>
</ul>
<p><strong>Cache performance</strong></p>
<p>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 <span class="keyword">i5/OS</span> may
remove from the cache some programs that the application requires.</p>
<p>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 <span class="keyword">i5/OS</span> from
removing Java programs from the cache. Alternatively, you can
increase the number that you specify for the os400.define.class.cache.maxpgms
property.</p>
<p>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.</p>
<p>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:</p>
<pre>os400.define.class.cache.file /QIBM/ProdData/Java400/QDefineClassCache.jar
os400.define.class.cache.hours 8760
os400.define.class.cache.maxpgms 10000</pre>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="selmod.htm">Select which mode to use when running a Java program</a></strong><br />
When you run a Java program, you can select which mode
you would like to use. All modes verify the code and create a Java program
object to hold the preverified form of the program.</li>
<li class="ulchildlink"><strong><a href="interprt.htm">Java interpreter</a></strong><br />
The Java interpreter is the part of the Java virtual
machine that interprets Java class files for a particular hardware
platform. The Java interpreter decodes each bytecode and runs a series
of machine instructions for that bytecode.</li>
<li class="ulchildlink"><strong><a href="transfor.htm">Static compilation</a></strong><br />
The Java transformer is an IBM<sup>®</sup> <span class="keyword">i5/OS</span> component
that preprocesses class files to prepare them to run using the iSeries Java virtual
machine. The Java transformer creates an optimized program object
that is persistent and is associated with the class file.</li>
<li class="ulchildlink"><strong><a href="jit.htm">Just-In-Time compiler</a></strong><br />
A Just-In-Time (JIT) compiler is a platform-specific compiler that generates machine instructions for each method as needed.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="tuning.htm" title="You should take several aspects of Java application performance into consideration when building a Java application for your iSeries server.">Tune Java program performance with IBM Developer Kit for Java</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="evenperf.htm" title="The iSeries Java virtual machine enables the trace of certain Java events.">Java event trace performance tools</a></div>
<div><a href="gc.htm" title="Garbage collection is the process of freeing storage that is used by objects that are no longer referred to by a program. With garbage collection, programmers no longer have to write error prone code to explicitly &#34;free&#34; or &#34;delete&#34; their objects. This code frequently results in &#34;memory leak&#34; program errors. The garbage collector automatically detects an object or group of objects that the user program can no longer reach. It does this because there are no references to that object in any program structure. Once the object has been collected, you can allocate the space for other uses.">Java garbage collection</a></div>
<div><a href="jnmiperf.htm" title="Native method invocation on an iSeries server may not perform as well as native method invocation on other platforms.">Java Native Method Invocation performance considerations</a></div>
<div><a href="jmiperf.htm" title="Method inlining can significantly improve method call performance. Any method that is final is a potential candidate for inlining.">Java method inlining performance considerations</a></div>
<div><a href="excperf.htm" title="The iSeries exception architecture allows versatile interrupt and retry capabilities. It also allows mixed language interaction. Throwing Java exceptions on an iSeries server may be more expensive than on other platforms. This should not affect overall application performance unless Java exceptions are routinely used in the normal application path.">Java exception performance considerations</a></div>
<div><a href="callperf.htm" title="Java method call traces provide significant performance information about the time that is spent in each Java method.">Java call trace performance tools</a></div>
<div><a href="profperf.htm" title="System wide central processing unit (CPU) profiling calculates the relative amount of CPU time that is spent in each Java method and all system functions in use by your Java program.">Java profiling performance tools</a></div>
</div>
<div class="reltasks"><strong>Related tasks</strong><br />
<div><a href="colpdc.htm" title="To collect Java performance data on an iSeries server, follow these steps.">Collect Java performance data</a></div>
</div>
</div>
</body>
</html>