Improving streamtool command performance

Using this procedure, you can setup a class data sharing archive to improve streamtool CLI performance. This only applies when using OpenJDK.

Before you begin

To generate the application class data sharing archive, you must tell Java to generate the archive by running a streamtool command. When the command exits, Java will generate the class data sharing archive in the specified path.
Before performing the steps to generate the class data sharing archive, you need the following:
  1. A configured local shell environment for Teracloud® Streams. To configure it, enter the following command:
      source product-installation-root-directory/7.2.0.1/bin/streamsprofile.sh 
  2. If using an enterprise domain: the STREAMS_ZKCONNECT environment variable must be set to point to the Zookeeper connection string.
  3. A running Teracloud® Streams domain and instance.

Procedure

  1. Set the STREAMTOOL_JVM_OPTIONS environment variable to specify to generate the class data sharing archive and where it should be stored. The path or name of the jsa file should be based on the version of OpenJDK and the version of Streams. The following command shows an example of storing the jsa file in a directory with the Streams version and file name containing the OpenJDK version:
      export STREAMTOOL_JVM_OPTIONS=-XX:ArchiveClassesAtExit=$HOME/.streams/7.2.0.1/var/st_17_0_14.jsa
  2. Run the following streamtool command, replacing mydomain and myinstance with the values for your environment. For more information about command syntax and options, enter streamtool man command-name.
      streamtool lsjob -d mydomain -i myinstance 
  3. When streamtool exits, Java will create the CDS archive file in the directory specified on the ArchiveClassesAtExit JVM option.
    Note: When the archive is generated after exiting streamtool, you might see this warning:
      [59.841s][warning][cds] Preload Warning: Verification failed for org.apache.logging.log4j.core.async.AsyncLoggerContext 
    This can be ignored. The named class will be loaded and verified at runtime and will not be pulled from the cache. The cache is still usable, the side affect will be minimal.
  4. To use the CDS archive file, you must reset the environment variable to use the new archive:
      export STREAMTOOL_JVM_OPTIONS=-XX:SharedArchiveFile=$HOME/.streams/7.2.0.1/var/st_17_0_14.jsa
  5. Optional: To verify that streamtool is using the cache, add the following logging option to the STREAMTOOL_JVM_OPTIONS environment variable: -Xlog:class+load.
    After verifying, remove the logging option from the following variable declaration:
      export STREAMTOOL_JVM_OPTIONS=-XX:SharedArchiveFile=$HOME/.streams/7.2.0.1/var/st_17_0_14.jsa -Xlog:class+load
  6. You should see, that the classes are loaded from the “shared objects file”. Here is a snippet of the log output when using the CDS:
      [0.052s][info][class,load] java.lang.Object source: shared objects file
      [0.052s][info][class,load] java.io.Serializable source: shared objects file
      [0.052s][info][class,load] java.lang.Comparable source: shared objects file
      [0.052s][info][class,load] java.lang.CharSequence source: shared objects file
      [0.052s][info][class,load] java.lang.constant.Constable source: shared objects file
      [0.052s][info][class,load] java.lang.constant.ConstantDesc source: shared objects file
      [0.052s][info][class,load] java.lang.String source: shared objects file
      [0.052s][info][class,load] java.lang.reflect.AnnotatedElement source: shared objects file

Results

The CDS archive will be used as long as the STREAMTOOL_JVM_OPTIONS contains the SharedArchiveFile option; and the class path used at archive creation time is the same as (or a prefix of) the class path used at run time.

The class data sharing archive needs to be regenerated for the following cases:
  1. The version of OpenJDK is updated.
  2. A patch is applied to the Streams installation jar files (should never have to do this unless directed by the Teracloud support).
  3. The version of Streams is updated. This includes fix packs.