The i5/OS Java Virtual Machine user classloader cache is a feature that allows the Java Virtual Machine to "remember" classes that have been loaded with user classloaders. This feature improves the startup performance of classes loaded by user class loaders by allowing the JVAPGMs created by user classloaders to be cached for reuse, avoiding JVAPGM creation and bytecode verification during the initial class load. WebSphere components (servlets and JSPs) are loaded by user classloaders and can take advantage of this feature.
For most applications, the default WebSphere setup provides the best solution. You should only consider the techniques described here if you are experiencing performance problems in the following areas:
Having a large number of these components, or complex components that access many classes in your application, makes application server startup time longer.
Component runtime during first-touch
These components are loaded the first time they are accessed after the application server is started:
If these components are complex or access many classes in your application, your first-touch times of these components are longer.
The user classloader cache improves performance in two ways:
Note in both cases the first time the class is loaded (for example before the cache is primed or after a class is changed), these functions are performed and the load is slower. Once the class is already in the cache, these functions are not performed, so subsequent loads are much quicker. There is no way to prime the cache with classes other than running your application.
Using the User Classloader Cache
To enable the user classloader cache, the Java system property os400.define.class.cache.file must be specified with a valid value. Other Java system properties may be optionally specified. Use the following Java system properties to enable and customize the user classloader cache:
mkdir /cache cd /cache
touch example
jar -cf MyAppCache.jar example
rm example
The value of the os400.define.class.cache.file property would be /cache/MyAppCache.jar.
This JAR file must not be on any classpath.
DSPJVAPGM can be used on this JAR file to determine how many JVAPGMs are cached. The Java programs field of the DSPJVAPGM display indicates how many JVAPGMs are cached, and the Java program size field indicates how much storage is consumed by cached JVAPGMs. Other fields of the display are meaningless when DSPJVAPGM is applied to a JAR file used for caching.
CHGJVAPGM can be used on this JAR file to change the optimization of the classes in the cache. CHGJVAPGM only affects programs currently in the cache. Classes added to the cache are optimized according to the other properties below.
os400.define.class.cache.hours
Specifies how long (in hours) an unused JVAPGM persists in the cache. When a JVAPGM has not been used and this timeout is reached, the JVAPGM is removed from the cache. The default value is 168 (one week). The maximum value is 9999 (about 59 weeks).
os400.define.class.cache.maxpgms
Specifies the maximum number of JVAPGMs the cache can hold. If this value is reached, the least recently used JVAPGMs is replaced first. The default value is 5000. The maximum value is 40000.
Note that other Java system properties, such as os400.defineClass.optLevel, can be used to customize how JVAPGMs are created in the cache.
To add Java system properties to an application server, perform these steps:
For example, to use the shipped cache JAR with a maximum of 10,000 JVAPGMs that have a maximum life of 1 year, you would add the following:
Property | Value |
---|---|
os400.define.class.cache.file | /QIBM/ProdData/Java400/QDefineClassCache.jar |
os400.define.class.cache.hours | 8760 |
os400.define.class.cache.maxpgms | 10000 |