Tools Home
Java Lock Monitor (JLM)
Back to TOP
General Description
JLM provides monitor hold time
accounting and contention statistics on monitors used in Java
applications and the JVM itself. Functionality provided includes:
-
Counters associated with contended locks
-
Total number of successful acquires
-
Recursive acquires - Number of times the monitor was
requested and was already owned by the requesting thread.
-
Number of times the requesting thread was blocked waiting on
the monitor because the monitor was already owned by another thread.
-
Cumulative time the monitor was held.
For platforms that support 3 Tier Spin Locking the following are also collected:
-
Number of times the requesting thread went through the inner (spin
loop) while attempting acquire the monitor.
-
Number of times the requesting thread went through the outer (thread
yield loop) while attempting acquire the monitor.
-
Full collection control via the rtdriver facility. Commands include:
-
jlmlitestart: collect counters only.
-
jlmstart: collect counters plus hold time accounting.
Note: Hold time accounting incurs a greater overhead.
-
jlmstop: stops data collection.
-
jlmdump: dumps collected data. Data collection continues.
-
Removal of Garbage Collection time from lock hold times
-
GC time is removed from hold times for all monitors held across a GC cycle.
Time and time units
Time (as in hold time) is
accounted for in units of cycles on all x86 platforms.
Supported Java Versions and Platforms
JLM is shipped as part of the IBM Runtime Environment for Linux, v1.4.0 and above.
Back to TOP
Usage Instructions
The best way to describe how to use JLM is via an example. The following assumptions are made:
-
You are using the IBM Runtime Environment for Linux, v1.4.0 and above.
-
You have installed the Performance Inspector™ for Linux tools package.
Our example executes a Java application, called "HelloWorld".
-
Start the Java application with the required command options
-
Start rtdriver
-
The minimum required rtdriver command is:
> rtdriver -l
This command will cause rtdriver to attempt to connect on the local machine and
then enter command mode.
-
To start collecting JLM data enter one of the following commands at the rtdriver command prompt:
jlmstart (collect counters and monitor hold times), or
jlmlitestart (collect counters only)
-
To dump JLM data enter jlmdump at the rtdriver command prompt.
JLM dump files are named log-jlm.#_pppp where #
is a sequence number, starting with 1 (one) for the first jlmdump and
incrementing by one for each subsequent jlmdump, and pppp is the
PID (process id) of the Java process. The files are located in the
Java current working directory (i.e. the directory from where Java was started).
-
To stop (turn off) JLM data collection enter jlmstop at the rtdriver command prompt.
Back to TOP
JLM Reported Statistics Description
The following descriptions refer to this sample JLM output file
produced by JProf.
Example of contention on one monitor
KEY:
- work (thread is busy)
| request lock
> lock ownership granted
~ thread holds lock
< thread releases lock
* thread waiting to be granted ownership
Thread 1: -----|>~~~~~~~~~~~~~~~~~~~~~~~~~~~<-----------------------------
Thread 2: ------------|**********************>~~~~~~~~~~~~<---------------
Thread 3: ------------------|******************************>~~~~~~<-------
Thread 4: ----------------------|**********************************>~~~<--
Hold time: |<------------------------->|
Thread 1
|<---------->| Thread 2
|<---->| Thread 3
|<->| Thread 4
Background
A monitor can be acquired in one of two ways:
-
Recursively, when the requesting thread already owns it.
-
Non-recursively, when the requesting thread does not
already own it. Non-recursive acquires can be further divided into:
-
Fast, when the requested monitor is not already owned
and the requesting thread gains ownership immediately. On platforms that
implement 3-Tier Spin Locking any monitor acquired while spinning is considered
a Fast acquire, regardless of the number of iterations in each tier.
-
Slow, when the requested monitor is already owned by
another thread and the requesting thread is blocked.
Fields in the report
-
JLM_Interval_Time: Time interval between jlmstart
and jlmdump. Time is expressed in the units appropriate for the hardware
platform.
-
%MISS: Percentage of the total GETS (acquires) where
the requesting thread was blocked waiting on the monitor.
%MISS = (SLOW / NONREC) * 100
-
GETS: Total number of successful acquires.
GETS = FAST + SLOW + REC
-
NONREC: Total number of non-recursive acquires. This
number includes SLOW gets.
-
SLOW: Total number of non-recursive acquires which
caused the requesting thread to block waiting for the monitor to become unowned.
This number is included in NONREC.
To calculate the number of non-recursive acquires in which
the requesting thread obtained ownership immediately (FAST), subtract SLOW
from NONREC. On platforms that support 3-Tier Spin Locking, monitors
acquired while spinning are considered FAST acquires.
-
REC: Total number of recursive acquires. A recursive
acquire is one where the requesting thread already owns the monitor.
-
TIER2: Total number of Tier 2 (inner spin loop)
iterations on platforms that support 3-Tier Spin Locking.
-
TIER3: Total number of Tier 3 (outer thread yield loop)
iterations on platforms that support 3-Tier Spin Locking.
-
%UTIL: Monitor hold time divided by JLM_Interval_Time.
Hold time accounting must be turned on.
-
AVER-HTM: Average amount of time the monitor was held.
Recursive acquires are not included because the monitor is already owned when
acquired recursively.
AVER-HTM = Total hold time / NONREC
-
MON-NAME: Monitor name or NULL (blank) if name not known.
Java and all Java-based trademarks are trademarks
of Sun Microsystems, Inc. in the United States, other countries, or both.
IBM is a trademark of International Business Machines Corporation in the United
States, other countries, or both
Other company, product or service names may be trademarks or service marks of
others.
MMX, Pentium, and ProShare are trademarks or registered trademarks of Intel
Corporation in the United States, other countries, or both.
[ Tools home ]