Calculating global contention percentages with the Db2 statistics trace
You can use the Db2 statistics trace to calculate global contention percentages for lock requests.
Procedure
To calculate global contention:
- Determine the total number of suspends that are caused by contention.
- Determine the total number of requests that went to XES.
- Divide the total number of suspends by the total number of requests.
- Multiply the result by 100.
Example
DATA SHARING LOCKING QUANTITY /SECOND /THREAD /COMMIT
--------------------------- -------- ------- ------- -------
GLOBAL CONTENTION RATE (%) 0.19
FALSE CONTENTION RATE (%) 0.04
P/L-LOCKS XES RATE (%) 36.47
LOCK REQUESTS (P-LOCKS) 107.4K 44.74 0.93 0.18
UNLOCK REQUESTS (P-LOCKS) 105.2K 43.82 0.91 0.18
CHANGE REQUESTS (P-LOCKS) 1453.00 0.61 0.01 0.00
SYNCH.XES - LOCK REQUESTS 1478.8K 616.16 12.77 2.48
SYNCH.XES - CHANGE REQUESTS 45450.00 18.94 0.39 0.08
SYNCH.XES - UNLOCK REQUESTS 810.0K 337.48 7.00 1.36
BACKGROUND.XES -CHILD LOCKS 0.00 0.00 0.00 0.00
ASYNCH.XES -CONVERTED LOCKS 108.00 0.04 0.00 0.00
SUSPENDS - IRLM GLOBAL CONT 3236.00 1.35 0.03 0.01
SUSPENDS - XES GLOBAL CONT. 334.00 0.14 0.00 0.00
SUSPENDS - FALSE CONT. MBR 863.00 0.36 0.01 0.00
SUSPENDS - FALSE CONT. LPAR N/A N/A N/A N/A
REJECTED - XES 31897.00 13.29 0.28 0.05
INCOMPATIBLE RETAINED LOCK 0.00 0.00 0.00 0.00
NOTIFY MESSAGES SENT 344.00 0.14 0.00 0.00
NOTIFY MESSAGES RECEIVED 106.00 0.04 0.00 0.00
P-LOCK/NOTIFY EXITS ENGINES 500.00 N/A N/A N/A
P-LCK/NFY EX.ENGINE UNAVAIL 0.00 0.00 0.00 0.00
PSET/PART P-LCK NEGOTIATION 38.00 0.02 0.00 0.00
PAGE P-LOCK NEGOTIATION 3026.00 1.26 0.03 0.01
OTHER P-LOCK NEGOTIATION 1520.00 0.63 0.01 0.00
P-LOCK CHANGE DURING NEG. 3072.00 1.28 0.03 0.01
For this example statistics trace, calculate global contention as follows:
Determine the total number of suspends that are caused by contention (
SUSPENDS - IRLM GLOBAL CONT + SUSPENDS - XES GLOBAL CONT. + SUSPENDS - FALSE CONT. LPAR).3236 + 334 + 863 = 4433Determine the total number of requests that went to XES (
SYNCH.XES LOCK REQUESTS + CHANGE REQUESTS + UNLOCK REQUESTS + BACKGROUND.XES CHILD LOCKS + ASYNCH.XES CONVERTED LOCKS + SUSPENDS IRLM GLOBAL CONT + XES GLOBAL CONT. + FALSE CONT. LPAR).1478800 + 45450 + 810000 + 0 + 108 + 3236 + 334 + 863 = 2338791Divide
the total number of suspends by the total number of requests.
4433 / 2338791 = .0019Multiply
the result by 100.
.0019 x 100 = 0.19The result indicates that the global contention rate is approximately 0.19%( A ). Because this is such a low rate of contention, it is probably not necessary to determine the amount of false contention.
What to do next
If the global contention rate is greater than 5%, investigate whether the following types of contention are contributing to the global contention:
- IRLM contention
- Lock resource contention. Use the lock trace to identify the objects. Some object definitions might need to be changed. For example, row-level locking might be needed for random access.
- XES contention
- XES understands only S or X locks. This is usually not an problem
- False contention
- If the size of the lock facility coupling size is too small, you might need to increase the size of the coupling facility lock table.