Visit Azul.com Support

Monitoring Thread CPU Time Use

With the Azul Zing Builds of OpenJDK (Zing) ThreadOpt functionality you can collect an application thread CPU time use data in one of two ways:

  1. Single CPU Time Use Snapshot

    Analysis of each of the process’s application thread’s CPU time use is done at a specific time followed immediately by setting the PU thread affinities of each application thread. The analysis can be repeated and affinities reset. The CPU time use collected for ach hread is cumulative.

  2. Monitor CPU Time Use - continuous process CPU time use snapshots + Continuous monitoring of each thread’s CPU time use and use of the data over a configurable, immediately previous interval to st the CPU thread affinities of each application thread. The analysis and setting of affinities can be continuous. ThreadOpt it disabled by default. You can enable it by using the -XX:+UseThreadOpt command-line option.

ThreadOpt comes with a set of options to control its behavior:

 
-XX:ThreadOptOptions=<list of options>

ThreadOpt requires 1 gigabyte of free Zing System Memory to run jstack to collect thread name information.

ThreadOpt monitoring and control in jConsole

You can both monitor and control ThreadOpt from jConsole. To do so,

  1. Start the Zing process with options that enable use of jConsole. For example:

     
    -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=3030 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
  2. Start jConsole and connect to the process:

     
    $JAVA_HOME/bin/jconsole
  3. Switch to the MXBeans tab.

  4. Click on the com.azul.threadopt entry to access ThreadOpt MXBeans.

List of options to control the behavior of ThreadOpt

Partitioning the running threads in the Java process between low and high CPU time consuming sets of application threads.

 
affinityToHighCPUThreadSet

Default affinity setting behavior and no option required for this setting. Set the affinity for each of the application threads that are in the set of high CPU time-consuming application threads to the entire set of CPU threads designated for running the high CPU time-consuming application threads.

affinityPer * options

Only one of the affinityPer* options should be specified. The last specified affinityPer * option overrides any other specified affinityPer* option. No "low=" or "high=" option can be specified with an affinityPer * option.

 
affinityPerCPUThread

Set the affinity for each of the application threads that are in the set of high CPU time-consuming application threads to a SINGLE CPU THREAD in the set of CPU threads designated for running the high CPU time-consuming application threads. This option is false by default.

 
affinityPerCore

Set the affinity for each of the application threads that are in the set of high CPU time-consuming application threads to a SINGLE PHYSICAL CORE in the set of physical cores designated for running the high CPU time-consuming application threads. This option is false by default.

 
affinityPerCPUThreadsOnPhysicalCore

Set the affinity for each of the application threads that are in the set of high CPU time-consuming application threads to ALL OF THE CPU THREADS RUNNING ON A SINGLE PHYSICAL CORE in the set of all physical cores designated for running the high CPU time-consuming application threads. This option is false by default.

low= and high= CPU thread list options

Use to specify a set of CPU threads to use for each of the two sets of threads, one for use by the low CPU time-consuming application threads and the other for the high CPU time-consuming. The numbers specified in the comma-separated lists must be valid CPU thread identifiers on the box where the application is running.

If either "low=" or "high=" is used then both options must be used. No "low=" or "high=" option can be specified with anyaffinityPer* option.

 
low=<list of CPU threads>

Override the automatically generated set of CPU threads to use for the low CPU time-consuming application threads. The format for the list is comma-separated numerical values. The "high=" option must also be specified if you are using the "low=" option.

 
high=<list of CPU threads>

Override the automatically generated set of CPU threads to use for the high CPU time-consuming application threads. The format for the list is comma-separated numerical values. The "low=" option must also be specified if you are using the "high=" option.

Controlling the setting of affinities using the threads name

 
threadRegExpLow

Use the regular expression that follows to match the name of the application threads that are to have their affinity set to the set of LOW CPU consuming CPU threads.

Threads with no name are not considered to be in the set of named threads to which the regular expression applies. Example: threadRegExpLow=.C1Compiler.

 
threadRegExpHigh

Use the regular expression that follows to match the name of the application threads that are to have their affinity set to the set of HIGH CPU consuming CPU threads.

Threads with no name are not considered to be in the set of named threads to which the regular expression applies. Example: threadRegExpHigh=.C1Compiler.

 
useThreadNames=<true|false>

Display thread name where relevant in list of threads. Value is true by default. A value of false will be overridden if threadRegExpLow and/or threadRegExpHigh are used.

To delay application analysis and application thread/CPU thread affinity time until a time after the start time of the application:

 
delaySecs=<float>

Seconds to wait before setting affinity (default value is 12 seconds). Example of 10 minutes: delaySecs=600

 
dhms=<HH:mm:ss>

Hours format: <24 hours>:<minutes>:<seconds>. Example of 10 minutes: dhms=00:10:00

 
dtodate=<yyyy-MM-dd-HH:mm:ss>

Future date format: <year>-<month>-<day>-<24 hours>:<minutes>:<seconds>

Example of 10 minutes:

 
Now: 2016-10-20-12:00:00 Future: 2016-10-20-12:10:00

Number of times to set the thread affinities

Repeat the evaluation and resetting of the affinity of the application threads when specified on the command line. Default value is false.

 
i=<int>

Number of iterations to repeat. Default value is 1.

 
tibas=<int>

Time interval between affinity settings, updating each application threads CPU thread affinity. Units are in seconds. Default value is 60 seconds.

 
skipFirstAffinitySetting

Skip the first affinity setting - enables the skipping of the first affinity setting so that more time can be devoted to completing the applications initialization. An alternative strategy is to use the MXBean interface to trigger the affinity setting when the conditions are optimal for affinity setting. Default value is false.

 
threshSecs=<int>

CPU time threshold in seconds for the Single CPU Time Use Snapshot mode only. Default value is 20 seconds. Example: threshSecs=30. Threshold for CPU consumption by a thread in the Java process. If the CPU consumption is lower than the threshold then the threads affinity is set to the low CPU time-consuming set of CPU threads.

If the CPU consumption is higher than the threshold then the thread''s affinity is set to the high CPU time-consuming set of CPU threads.

Java process application thread CPU monitoring

 
monCPUUse

Enables the periodic monitoring system that collects snapshots of the CPU time use of each thread in the Java process. Enables Monitor CPU Time Use mode. Default value is false which will cause ThreadOpt to use Single CPU Time Use Snapshot mode.

 
monPercentCPUTimeUseThresh=<int>

Threshold value that represents the percent of the CPU time consumed by a thread, at or above which the application thread is added to the set of application threads in the high CPU time-consuming set of application threads. Threshold value when using the Monitor CPU Time Use mode only. In the default case, any application thread that uses 20 percent or more of the CPU time available to that thread in a monitoring interval is added to the set of high CPU time-consuming application threads. Default value is 20.

 
monCPUHistSize=<int>

Number of historical snapshots to save for consulting when making decisions about a thread’s CPU time consumption. For each thread, the difference between the CPU time use in the most recent snapshot and the oldest is used to compare against the CPU time threshold. If the CPU time consumption for that thread is greater than or equal to the threshold value then the thread is in the set of high CPU time-consuming threads for that interval. Default value is 6. Minimum value is 2 to provide better comparisons over a specified interval for long-running applications.

 
montibs=<int>

Time interval between taking snapshots of the CPU use of the threads in the Java process in seconds. Together with the value of CPUHistSize, determines the time interval over which each threads CPU time consumption is calculated. Default value is 60 seconds.

 
montibwtn=<int>

Monitoring time interval between writing application threads names to the log file, in units of seconds. Requires montibs value to be less than montibwtn value to trigger printing of montibwtn at regular intervals. (Writing to the log file is determined by the montibs time interval. If the time since last writing the application threads names has been exceeded then that information will also be written.) Minimum value is 10 seconds. If not specified, value (seconds): 60, 240, 300, 600, 600, …​

 
montibwttca=<int>

Monitorings time interval between writing application thread CPU set affinity setting to the log file, in units of seconds. Requires montibs value to be less than montibwttca value to trigger printing of montibwttca at regular intervals. (Writing to the log file is determined by the montibs time interval. If the time since last writing the thread CPU set affinity has been exceeded then that information will also be written.) Minimum value is 10 seconds. Default value is 300 seconds.

 
monDelaySecs=<float>

Delay time between the start of the program and taking the first snapshot of the CPU time use by the application threads. Accuracy is in milliseconds. Default value is 12 seconds.

 
monDelayHMS=<HH:mm:ss>

Monitor start delay time in hours, minutes, seconds format: <24 hours>:<minutes>:<seconds>

 
monDelayToDate=<yyyy-MM-dd-HH:mm:ss>

Monitor start time in future date format: <year>-<month>-<day>-<24 hours>:<minutes>:<seconds>

 
monSavePerfData

As each performance snapshot is collected, append the snapshot to the end of a file that has the name that follows the format: YearMoDa HrMnSc Ms. Example:

 
/tmp/zing_threadopt_monitor_20160904_153750_097_pid_27746.log [source, shell]

Default is to not create or write to the log file.

Usage Examples:

 
$JAVA_HOME/bin/java -XX:+UseThreadOpt \ -XX:ThreadOptOptions='i=2 affinityPerCore tibas=120' \ ThreadOptTest -tset 2 0 0 60 3600 0,2,4,6,8,10,10,8,6,4,2,0 UpAndDown
 
$JAVA_HOME/bin/java -XX:+UseThreadOpt \ -XX:ThreadOptOptions='monCPUUse delayMS=20000 r affinityPerCore tibas=120' \ ThreadOptTest -tset 2 0 0 10 3600 0,0,0,10,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,10,6,4,2,0,0,0,0 spiky