Вы находитесь на странице: 1из 97

Threadsafe Conversion Techniques for CCS

Applications
Russ Evans
russevans(evansgroupconsulting.com
The Evans Group, Inc.
Session 1064
Copyright (c) 2009, The Evans Group, nc. 2
Objectives
History of Multithreading
The Open Transaction Environment
OTE and DB2
Controlling Threadsafe
Determining if a program is Threadsafe
Making programs Threadsafe
dentifying candidates for Threadsafe conversion
Recommendations
Copyright (c) 2009, The Evans Group, nc. 3
History of Multithreading
CCS as a Single TCB
Most efficient on a uni-processor
"Quasi-Reentrancy
ssues:
Runaway tasks
OS Waits = Region Wait
Many restricted OS and COBOL Commands
Limited by speed of one processor
Copyright (c) 2009, The Evans Group, nc. 4
History of Multithreading
CCS Exploiting Multiple Processors
Multiple TCBs
Primary TCB is "QR, Quasi-Reentrant
Additional TCBs for:
VSAM
DB2
Program Loader
etc.
Copyright (c) 2009, The Evans Group, nc. 5
History of Multithreading
CCS and DB2
Separate TCB ('thread') for each DB2 Request
Task is switched to DB2 TCB for DB2 work, DB2 system
code runs on DB2 TCB
Significant workload shifted to DB2 TCBs, but
measurable overhead from TCB switching
Copyright (c) 2009, The Evans Group, nc. 6
Open Transaction Environment
Transaction runs under own TCB
ntroduced in TS 1.3 for Java
DB2 Support added for TS 2.2
Supports full OS function
Allows true Multitasking in CCS
Pseudo-reentrancy no longer aIIowed
Enhanced level of confusion among systems
programmers
Copyright (c) 2009, The Evans Group, nc. 7
OTE and DB2
QR TCB
Task Starts
EXEC CICS
EXEC SQL
Application Code
EXEC SQL
Open TCB
DB2 Code executes
DB2 Code completes
DB2 Code executes
DB2 Code completes
Without ThreadsaIe
Copyright (c) 2009, The Evans Group, nc. 8
OTE and DB2
QR TCB
Task Starts
EXEC CICS
EXEC SQL
Task Termination
Open TCB
DB2 Code executes
Application Code
DB2 Code executes
Task completes
With ThreadsaIe
Copyright (c) 2009, The Evans Group, nc. 9
L8 TCB
DB2 SYSTEM CODE
L8 TCB
DB2 SYSTEM CODE
L8 TCB
DB2 SYSTEM CODE
CCS and OTE
Without ThreadsaIe
QR TCB
Active Task
OTE
L8 TCB
DB2 SYSTEM CODE
Copyright (c) 2009, The Evans Group, nc. 10
Active Task
Active Task
Active Task
L8 TCB
DB2 SYSTEM CODE
L8 TCB
DB2 SYSTEM CODE
L8 TCB
DB2 SYSTEM CODE
CCS and OTE
With ThreadsaIe
QR TCB
Active Task
OTE
L8 TCB
DB2 SYSTEM CODE
Active Task
Copyright (c) 2009, The Evans Group, nc. 11
So, What's the Problem
Consider a common use of CWA, holding a
record counter used to make keys unique:
MOVE CWA-REC-COUNT TO KEY-UNQUE-
PORTON
ADD +1 TO CWA-REC-COUNT
EXEC CCS WRTE MPORTANT-FLE
RDFLD(KEY-COMPLETE)
Copyright (c) 2009, The Evans Group, nc. 12
So, What's the Problem Continued...
Now, the same program running Threadsafe:
OTE TCB #1 OTE TCB #2
MOVE CWA-REC-COUNT TO
KEY-UNIQUE-PORTION
ADD 1 TO CWA-REC-COUNT
EXEC CICS WRITE IMPORTANT-FILE
RIDFLD(KEY-COMPLETE)
MOVE CWA-REC-COUNT TO
KEY-UNIQUE-PORTION
ADD 1 TO CWA-REC-COUNT
EXEC CICS WRITE IMPORTANT-FILE
RIDFLD(KEY-COMPLETE)
Error, DUPREC
And, CWA-REC-COUNT is incremented by 2
Copyright (c) 2009, The Evans Group, nc. 13
Definitions
Define "threadsafe
1. "A threadsafe 57og7am is one that does not modify any
area of storage that can be modified by any other
program at the same time, and does not depend on any
area of shared storage remaining consistent between
machine instructions.
Copyright (c) 2009, The Evans Group, nc. 14
Controlling Threadsafe
At the program level:
New parameter on Program Definition
CONCURRENCY=QUASRENT
Not Threadsafe
CONCURRENCY=THREADSAFE
At the region level, new ST parm:
FORCEQR=YES/NO
FORCEQR=YES All programs run non-Threadsafe
FORCEQR=NO Programs follow
CONCURRENCY parm on program
definition
Copyright (c) 2009, The Evans Group, nc. 15
dentifying Threadsafe Programs
No automated method of identification
BM Tool can help
Rules of thumb:
COBOL and PL/1 must be LE
All programs must be re-entrant
Aps with no affinities are more likely to be threadsafe
Copyright (c) 2009, The Evans Group, nc. 16
dentifying Threadsafe Programs
Ensure programs are re-entrant:
COBOL:
Compile with RENT
Link with RENT
Assembler:
Code review, possible coding changes required
Assemble/Link with Rent
CCS:
RENTPGM=PROTECT
Adjust RDSA/ERDSA sizes
Non-reentrant activity will generate DFHSR0622 followed by
S0C4/ASRA
Possible conflicts with debuggers
Copyright (c) 2009, The Evans Group, nc. 17
dentifying Threadsafe Programs
o automated method of identification
CONCURRENCY
parm is a
57omise
by you, not an order to CCS
Copyright (c) 2009, The Evans Group, nc. 18
Definitions
Define "threadsafe
1. "A threadsafe 57og7am is one that does not modify any
area of storage that can be modified by any other program
at the same time, and does not depend on any area of
shared storage remaining consistent between machine
instructions.
2. "A program defined as CONCURRENCY=THREADSAFE
is one that will be aIIowed to run on an open TCB.
Copyright (c) 2009, The Evans Group, nc. 19
dentifying Threadsafe Programs
Continued...
There is a tool available to help start...
Utility DFHESUP will scan for CCS commands
commonly used in non-threadsafe applications
Use command table DFHEDTH
Copyright (c) 2009, The Evans Group, nc. 20
dentifying Threadsafe Programs
Continued...
There is a tool available to help start...
dentifies programs that issue:
ADDRESS CWA
EXTRACT EXT
GETMAN SHARED
Consider adding:
LOAD PROGRAM () HOLD
Copyright (c) 2009, The Evans Group, nc. 21
dentifying Threadsafe Programs
Continued...
CCS LOAD MODULE SCANNER UTLTY
SCAN PERFORMED ON Mon Oct 20 08:01:46 2003 USNG TABLE
DFHEDTH
SUMMARY LSTNG OF CCS.NOT.TSAFE.LOADLB
=====================================
Module Name Commands Found Language
ASMPGM1 1 Assembler
COBPGM1 1 Cobol
LOAD LBRARY STATSTCS
=======================
Total modules in library = 63
Total modules Scanned = 63
Total CCS modules/tables not scanned = 0
Total modules possibly containing requested commands = 2
Copyright (c) 2009, The Evans Group, nc. 22
dentifying Threadsafe Programs
Continued...
Programmer must:
Review each program reported
Determine if any non-threadsafe activity
Review all calls/LNKs/XCTLs out of program to see if
addressability to area is passed
f yes, review called programs to determine if any non-
threadsafe activity
Copyright (c) 2009, The Evans Group, nc. 23
dentifying Threadsafe Programs
Continued...
dentify non-threadsafe activity:
F CWA-HR-AP-AVALABLE = 'YES'
MOVE CWA-FLE-NAME TO WS-DD-OUT
ADD +1 TO CWA-REC-CNTR
F CWA-USE-FLD >= WS-GOOD-FELD
Copyright (c) 2009, The Evans Group, nc. 24
Making Programs Threadsafe
1) Alter the code to serialize the shared storage access
A) Use CCS to automatically ensure serialization
B) Manually ensure serialization
2) Do nothing
AIter identiIying non-ThreadsaIe code you have
two choices:
Copyright (c) 2009, The Evans Group, nc. 25
Making Programs Threadsafe continued...
Leave non-threadsafe programs QUASRENT
CCS will switch to QR on LNK or XCTL (But.not fo7
CALL!)
Access to shared storage is automatically serialized
II shared storage use is limited to Iew programs:
Copyright (c) 2009, The Evans Group, nc. 26
OTE TCB #1 OTE TCB #2
MOVE CWA-REC-COUNT TO
KEY-UNIQUE-PORTION
ADD 1 TO CWA-REC-COUNT
EXEC CICS WRITE IMPORTANT-FILE
RIDFLD(KEY-COMPLETE)
Wait Ior QR TCB to become available
Making Programs Threadsafe continued...
Our CWA Issue Resolved by Marking Program QUASIRENT
Switch to QR TCB
Switch to QR TCB
MOVE CWA-REC-COUNT TO
KEY-UNIQUE-PORTION
Copyright (c) 2009, The Evans Group, nc. 27
Making Programs Threadsafe continued...
Advantages:
No coding changes, so quick implementation
Disadvantages:
Additional TCB switching overhead
Maintenance issues
All programs that access these areas must also remain
QUASRENT
Copyright (c) 2009, The Evans Group, nc. 28
Making Programs Threadsafe continued...
What is this data used for?
s this data still used/required?
Does it matter if the data is inaccurate?
Must lock the data for both read and update, or just for
update?
Assume OPS tran to display CWA-REC-COUNT:
Value is potentially incorrect prior to its display
Need only be approximate
Leave program unchanged
Copyright (c) 2009, The Evans Group, nc. 29
Making Programs Threadsafe continued...
"Wrap access in CCS ENQ/DEQ
For Assembler, use CS/CDS
Move data to a threadsafe but serialized facility:
CCS Maintained Data Table
DB2 table
Coupling Facility
To serialize access to shared storage:
Copyright (c) 2009, The Evans Group, nc. 30
Making Programs Threadsafe continued...
OS ENQ
Difficult to ensure that program is on L8 at time of ENQ
TCLASS
Performance issues from bottlenecks
Serialization techniques to avoid:
Copyright (c) 2009, The Evans Group, nc. 31
Making Programs Threadsafe continued...
The Compare and Swap works on a fullword value. Since the storage area is only locked during execution of the CS,
it can be changed while the program is preparing its update. To handle this situation, the CS takes three
operands:
What the value was when I first accessed it
What I want the new value to become
The storage area in question
When the CS executes, it first locks the storage area. Then, it compares the actual value in the storage area to
the value you say it should be. If these values match, then the data in the storage area is replaced with the
value you asked for, and the condition code is zero.
If the values don't match, it means that some other task has updated the area after you retrieved its value. The
data in the storage area is not replaced, and the condition code is set to non-zero.
In this example, we are attempting to increment a counter by one. If the CS fails, we simply acquire the new
current value and try again.
The Assembler Compare & Swap Command
Copyright (c) 2009, The Evans Group, nc. 32
Making Programs Threadsafe continued...
TCJUNT DS 0H
L R15,CWA_RC_CJUNT pick up the rec number
LA R0,1(,R15) increment the use count
CS R15,R0,CWA_RC_CJUNT save the new count
BN TCJUNT data altered, try again
ST R15,K_UNIQU_PJRTIJN build key
The Assembler Compare & Swap Command
Copyright (c) 2009, The Evans Group, nc. 33
Making Programs Threadsafe continued...
Limited to 4 or 8 bytes max
Requires Assembler experience or called routine
Potential for a spin loop.
CS Issues:
Copyright (c) 2009, The Evans Group, nc. 34
OTE TCB #1 OTE TCB #2
EXEC CICS ENQ RESOURCE()
MOVE CWA-REC-COUNT TO
KEY-UNIQUE-PORTION
ADD 1 TO CWA-REC-COUNT
EXEC CICS DEQ RESOURCE()
EXEC CICS WRITE IMPORTANT-FILE
RIDFLD(KEY-COMPLETE)
Making Programs Threadsafe continued...
Our CWA Issue Resolved by Using ENQ/DEQ
EXEC CICS ENQ RESOURCE()
.
.
.
MOVE CWA-REC-COUNT TO
KEY-UNIQUE-PORTION
Copyright (c) 2009, The Evans Group, nc. 35
Making Programs Threadsafe continued...
CPU Cost
Potential bottleneck
Limit ENQ duration by issuing DEQ as soon as possible
Ensure no possibility of deadly embrace
ENQ Issues:
Copyright (c) 2009, The Evans Group, nc. 36
OTE TCB #1 OTE TCB #2
EXEC CICS GET COUNTER()
MOVE COUNTER-VALUE TO
KEY-UNIQUE-PORTION
EXEC CICS WRITE IMPORTANT-FILE
RIDFLD(KEY-COMPLETE)
Making Programs Threadsafe continued...
Our CWA Issue Resolved by Using Named Counter
EXEC CICS GET COUNTER()
MOVE COUNTER-VALUE TO
KEY-UNIQUE-PORTION
EXEC CICS WRITE IMPORTANT-FILE
RIDFLD(KEY-COMPLETE)
Copyright (c) 2009, The Evans Group, nc. 37
Making Programs Threadsafe continued...
Requires coupling facility
GET is not a threadsafe command
Named Counter Issues:
Copyright (c) 2009, The Evans Group, nc. 38
Making Programs Threadsafe continued...
All programs that access the same shared
storage area in the same CCS region must be
converted before any of these programs are
marked as Threadsafe!
Regardless oI which method, remember:
Copyright (c) 2009, The Evans Group, nc. 39
Diagnosing Threadsafe Problems
Threadsafe problems most likely to occur during peak
time.
Stress testing more likely to bring out threadsafe
problems.
Best way to ensure success is strong application
knowledge.
Be thorough in your review.
No way to prove threadsaIe!
Copyright (c) 2009, The Evans Group, nc. 40
Diagnosing Threadsafe Problems
Errors based on probability
Difficult to force simultaneous execution of code path
Use stress testing
Set MAXTASK high
Set DSALMTs high
Set SYSDUMPNG on!
Use driver program to issue large number of STARTs
ow to tell when Testing is Complete?
Copyright (c) 2009, The Evans Group, nc. 41
Diagnosing Threadsafe Problems
Difficult to identify
"mpossible behavior likely to be threadsafe issue
Use CCS auxtrace
Use homegrown application trace
CCS system dump
Unpredictable Results Means Just That!
Copyright (c) 2009, The Evans Group, nc. 42
Diagnosing Threadsafe Problems
Macros such as ENQ and DEQ must run on same TCB
ntervening user code can force TCB switch
Second macro in pair fails
Macros include:
ENQ/DEQ
ATTACH/DETACH
Paired MVS macros that need same TCB
Copyright (c) 2009, The Evans Group, nc. 43
Diagnosing Threadsafe Problems
COBPGM
CALL 'ASMPGM1'
USNG PARM-
LST.
A Statically Called Assembler Program Isn`t ThreadsaIe
AShPCh1
LA R13.SAvARA
S1h R14.R1!.1!{R13)
.
.
Lh R14.R1!.1!{R13)
R R14
.
.
SAvARA LS 18F
Copyright (c) 2009, The Evans Group, nc. 44
Diagnosing Threadsafe Problems
Because ASMPGM1 issues no CCS commands, the code
runs normally in a non-threadsafe environment
CCS is not notified for calls
Simultaneous access to SAVEAREA results in overlay
Probable S0C4
dentifiable in test via RENTPGM=PROTECT
All Called Routines Run on TCB of the Caller
Copyright (c) 2009, The Evans Group, nc. 45
Diagnosing Threadsafe Problems
Possible solutions:
1. Convert ASMPGM1 to Command Level
2. Alter COBPGM to pass address of RSA
3. Leave COBPGM non-Threadsafe
All Called Routines Run on TCB of the Caller
Copyright (c) 2009, The Evans Group, nc. 46
Definitions
Define "threadsafe
1. "A threadsafe 57og7am is one that does not modify any
area of storage that can be modified by any other
program at the same time, and does not depend on any
area of shared storage remaining consistent between
machine instructions.
2. "A program defined as
CONCURRENCY=THREADSAFE is one that will be
allowed to run on an open TCB.
3. "A threadsafe CCS command is one that is aIIowed to
run under an open TCB. A non-threadsafe command is
one that is not aIIowed to run under an open TCB
Copyright (c) 2009, The Evans Group, nc. 47
Non-Threadsafe CCS Commands
Many commands not Threadsafe
Use of non-Threadsafe commands is 1: supported
by CCS
CCS detects non-threadsafe command and switches
task to QR TCB
Task remains on QR TCB until next SQL
Worst case: no CPU improvement if 0;07 SQL stmt
followed by non-threadsafe cmd
Copyright (c) 2009, The Evans Group, nc. 48
Non-Threadsafe CCS Commands
A list of the commands that are threadsafe can be found in
the $ Application Programming Reference Manual,
under CICS th7eadsafe commands in the API.
A list of the threadsafe SP commands can be found in the
$ $stem Programming Reference Manual, in Appendix
D, %h7eadsafe SPI commands
Copyright (c) 2009, The Evans Group, nc. 49
Non-Threadsafe CCS Exits
Significant area of concern
Task switched to QR for duration of exit, then back to
Open TCB
nfrequently referenced exits less of a problem
Frequently referenced exits (eg., XEN) are a major
performance problem
XRMN/OUT and Dynamic Plan Selection most
worrisome
Worst case: significant (20%++?) increase in CPU
utilization.
Can cause CPU impact even if FORCEQR=YES
Copyright (c) 2009, The Evans Group, nc. 50
Non-Threadsafe CCS Exits
Use DFH0STAT to identify exits in use
Select DB2, User Exit and Global User Exit options
dentifies all active exits by program name,
CONCURRENCY option, exit point, and GWA usage
Shows Dynamic Plan exits
dentify vendor exits and contact vendor
Do not mark threadsafe without vendor OK
Do not convert with heavily used QUASRENT exits
Review homegrown exit code to ensure threadsafe
Copyright (c) 2009, The Evans Group, nc. 51
Using BM Utility DFH$MOLS
BM supplied utility to analyze SMF 110 records
Provides detailed report
One page / task
Storage utilization
CPU utilization
By TCB type
Response time
Can use pre-generated MCT A$
Activate monitoring with CEMT
SET MON ON PER
Flush buffers with CEMT
SET MON ON NOP
Copyright (c) 2009, The Evans Group, nc. 52
Using BM Utility DFH$MOLS

S1cp 1. Ln1oad da1a !om 1hc ShF da1a sc1s

ShFLLhP XC PCh=1FAShFLP
1hLL1 LL LSh=SYS1.L00!.hAh11.L1SP=SR.AhP={`LFSP=8SS38`)
1hLL! LL LSh=SYS1.L00!.hAh1!.L1SP=SR
1hLL3 LL LSh=SYS1.L00!.hAh13.L1SP=SR
L1LL1 LL LSh=?????.ShF.LA1A1.L1SP={hW.CA1LC).
SPAC={CYL.{S0.10)).Lh11=SYSLA
SYSPR1h1 LL SYSL1=A
SYS1h LL
1hLL{1hLL1.P11hS{LLhP))
1hLL{1hLL!.P11hS{LLhP))
1hLL{1hLL3.P11hS{LLhP))
L1LL{L1LL1.1YP{110{1)))
Use FASMFDP to extract the 110 records
NDDx points to your
SMF datasets. You
can use either active
datasets or archives
OUTDD1 points
to the output
dataset that
holds the
extracted 110
records
Use an NDD control
statement to describe
each SMF file used as
input.
The OUTDD control
statement describes your
output file and the record
types to be extracted.
We're using 110 subtype 1
records
Copyright (c) 2009, The Evans Group, nc. 53
Using BM Utility DFH$MOLS
PRh1 XC PCh=LFShLS
S1PL1 LL LSh=SYS!.C1CS1S31.C1CS.SLFLAL.L1SP=SR
1hPL1 LL LSh=?????.ShF.LA1A1.L1SP=LL
SR1WK01 LL SPAC={CYL.{S.1)).Lh11=SYSLA
SR1WK0! LL SPAC={CYL.{S.1)).Lh11=SYSLA
SR1WK03 LL SPAC={CYL.{S.1)).Lh11=SYSLA
SR1WK04 LL SPAC={CYL.{S.1)).Lh11=SYSLA
SR1WK0S LL SPAC={CYL.{S.1)).Lh11=SYSLA
SR1L1AC LL SYSL1=A
SYSL1 LL SYSL1=A
SYSPR1h1 LL SYSL1=A
SYSAhL LL SYSL1=A
SYSLLLhP LL SYSL1=A
SYS1h LL
SLC1 1RAh1L=1n1.1n!
LA1 S1AR1=03!3!008

Use DFH$MOLS to format the extracted records


NPUT DD points to
OUTDD dataset
from previous step.
The report is
written to
SYSPRNT Use the SELECT
TRAND cards to limit
your report.
Use the DATE START card
to limit your report
Copyright (c) 2009, The Evans Group, nc. 54
Using BM Utility DFH$MOLS
F1LLhAhLh1h1RPR1L1h1RPR1L

LF1ASK C001 1RAh CS!C3F1 SC1


LF1Rh C00! 1Rh C3L7F8F4 CP84
LFC1CS C089 LSR1L C3C9C3! C4F!F!F4 C1CSL!!4
LF1ASK C004 11YP 3L80000 1
LFC1CS 100S S1AR1 L8!7ALC91L781 !0080S!3
10.S3.48.988349
LFC1CS 1008 S1P L8!7ALL3A740 !0080S!3
10.S3.48.971047
LF1ASK P031 1RAhhLh 0000S13C S13
LF1ASK A109 1RAhPR1 00000001 1
...
LF1Rh C111 LLhAh !F0F13 C3L7F8F4 S011CP84
LFPRC C071 PChhAh CS!L74 !CSC3F1 SPLSC1
LF1ASK C097 h1LWPX C!C8C4LS CS34! F0F13C3 L7F8F400 00000000
Lh1.S011CP84
LF1ASK C098 h1LWSX L8!7ALC9L100001
LFC1CS A131 PRRCh1 00000001 1
LF1ASK 113! RhLW1L L8!7ALC9L10!1 !0080S!3
10.S3.48.988S!9
LFC1CS C187 SRvCLShh C3C9C3! 40404040 C1CS
...
LF1ASK C183 FC1YhAh C3L7F8F4 CP84
LF1ASK A184 1RAhFLAC 400080000!000000
LF1Rh A18S 1Rh1hF 01000191
...
LF1ASK C08! 1RhCRP1L 180FC!C8C4LSCS3...
LF1Rh C197 h11L C!C8C4LS CS34040 Lh1
LF1Rh C198 RLLhAh !F0F13 C3L7F8F4 S011CP84
Copyright (c) 2009, The Evans Group, nc. 55
Non-Threadsafe CCS Exits
DFH$MOLS report of non-threadsafe program:
L!R0C1 14879
LSRCPL1 00.00.01.11981 !9783
SLSP11h 00.00.01.79190 !9783
L1SPW11 00.00.01.899S0 !978!
0RL1SP1 00.00.00.378!7 1488!
0RCPL1 00.00.00.01S88 1488!
KY8L1SP1 00.00.03.87381 14880
KY8CPL1 00.00.01.10!1! 14880
L8CPL1 00.00.01.10!1! 14880
Rh111h 00.00.03.37489 14880
Copyright (c) 2009, The Evans Group, nc. 56
Non-Threadsafe CCS Exits
DFH$MOLS report of non-threadsafe EXT:
L!R0C1 14879
LSRCPL1 00.00.01.1S487 S9S19
SLSP11h 00.00.0!.71038 S9S19
L1SPW11 00.00.0!.41S34 S9S18
0RL1SP1 00.00.00.83384 !9780
0RCPL1 00.00.00.014S8 !9780
KY8L1SP1 00.00.03.3S8!! !97S9
KY8CPL1 00.00.01.14011 !97S9
L8CPL1 00.00.01.14011 !97S9
Rh111h 00.00.0!.9!8S! 14880
Copyright (c) 2009, The Evans Group, nc. 57
dentifying Candidates for Threadsafe
QR TCB
Task Starts
EXEC CICS
EXEC SQL
Task Termination
Open TCB
DB2 Code executes
Application Code
DB2 Code executes
Task completes
CPU reduction with DB2 and ThreadsaIe is achieved by reducing
the number oI TCB switches
Copyright (c) 2009, The Evans Group, nc. 58
dentifying Candidates for Threadsafe
Example from GE Convert to Threadsafe:
An 8% CPU reduction
Copyright (c) 2009, The Evans Group, nc. 59
dentifying Candidates for Threadsafe
Reduce the totaI number of TCB switches:
Heavily utilized programs with large number of SQL
Heavily utilized programs with small number of SQL
Lightly utilized programs with large number of SQL
Copyright (c) 2009, The Evans Group, nc. 60
dentifying Candidates for Threadsafe
Maximum potential CPU savings is a function of
Program use and SQL count:
Potential = Program Use X (SQL count 1)
Copyright (c) 2009, The Evans Group, nc. 61
dentifying Candidates for Threadsafe
QR TCB
Task Starts
EXEC SQL
EXEC SQL
Task Termination
Open TCB
DB2 Code executes
Application Code
EXEC CICS WRITEQ TD
DB2 Code executes
Task completes
Any additional TCB switches supporting non-ThreadsaIe activity
will reduce the potential savings
Copyright (c) 2009, The Evans Group, nc. 62
dentifying Candidates for Threadsafe
CPU savings is produced every time an SQL statement
is issued when the task is already on the L8 TCB.
CPU savings is maximized when most SQL statements
are issued while on the L8 TCB
Tools to identify actuaI savings vs. 5otentiaI savings:
SMF Statistics
CCS Auxiliary Trace
Can be run in test regions prior to Threadsafe
conversion
Copyright (c) 2009, The Evans Group, nc. 63
dentifying Candidates for Threadsafe
DFH$MOLS reports on the number of SQL calls per
task:
L!R0C1 00004!0 !0000
LSRL1SP1 001A1C7!00009C4S 00.00.!7.37948 4000S
LSRCPL1 0004978400009C4S 00.00.04.81491 4000S
SLSP11h 0004003300009C4S 00.00.04.19S1! 4000S
L1SPW11 0004783S00009C44 00.00.04.87848 40004
0RL1SP1 00037L800004!3 00.00.04.09S38 !0003
0RCPL1 00008900004!3 00.00.00.S8491 !0003
hSL1SP1 000010L800000001 00.00.00.08899 1
hSCPL1 0000008S00000001 00.00.00.00181 1
RL1SP1 000010L800000001 00.00.00.08899 1
RCPL1 0000008S00000001 00.00.00.00181 1
KY8L1SP1 0018!3C!00004!1 00.00.!3.!1S13 !0001
KY8CPL1 00040L3400004!1 00.00.04.!4838 !0001
L8CPL1 00040L3400004!1 00.00.04.!4838 !0001
0RhLLLY 000!801300004!! 00.00.0!.8!174 !000!
Copyright (c) 2009, The Evans Group, nc. 64
dentifying Candidates for Threadsafe
DFH$MOLS on the same task running Threadsafe in
test
L!R0C1 00004!0 !0000
LSRL1SP1 001001800009C43 00.00.18.78499 40003
LSRCPL1 0004L0S00009C43 00.00.0S.04993 40003
SLSP11h 000!S3800009C43 00.00.0!.44003 40003
L1SPW11 000!3L4400009C4! 00.00.0!.34809 4000!
0RL1SP1 000388800004!! 00.00.03.S87!3 !000!
0RCPL1 0000F7AS00004!! 00.00.01.0143S !000!
KY8L1SP1 000C9AF00004!1 00.00.13.!1778 !0001
KY8CPL1 0003L94000004!1 00.00.04.03SS8 !0001
L8CPL1 0003L94000004!1 00.00.04.03SS8 !0001
0RhLLLY 0001S1C100004!1 00.00.01.38344 !0001
LSChLLY 000!S3400009C4! 00.00.0!.44000 4000!
Copyright (c) 2009, The Evans Group, nc. 65
dentifying Candidates for Threadsafe
SMF Statistics
Look at ratio of (Mode Switches / 2) SQL Calls
High ratio indicates many non-threadsafe commands
Low ratio shows maximizing savings
Ratio > 1 indicates non-threadsafe exits
Copyright (c) 2009, The Evans Group, nc. 66
dentifying Candidates for Threadsafe
The ratio for this task is (40,003/2) : 20,000, or
1:1.
While the 5otentiaI CPU savings for marking
this program as Threadsafe is large (40,000
mode switches) the actuaI CPU savings is
ze7o.
We use CCS Aux Trace to find out why.
Copyright (c) 2009, The Evans Group, nc. 67
dentifying Candidates for Threadsafe
Identifying the non-%h7eadsafe Commands Using
DFHEISUP.
Filter DFHEDNT contains a list of all commands that are not
threadsafe for your release of CCS.
Identifying the non-%h7eadsafe Commands Using Auxt7ace
L8000 DS 0002 DSAT ENTRY CHANGE_MODE QR
Will follow the "entry trace for non-Threadsafe CCS commands
Use trace parms:
SHORT,TRAND=xxxx,TYPETR=(DS0002-0003,AP00E1,AP2520-
2521)
(NOTE: Change mode trace entries require DS trace level 2)
Copyright (c) 2009, The Evans Group, nc. 68
dentifying Candidates for Threadsafe
001SS 0R LS 0003 LSA1 X11 CAhChLK LLhLhAh{0R) R19SA81!
001SS L800 LS 0003 LSA1 X11 CAhChLK R180098L00
001SS L800 AP !S!1 Rh X11 CLAPPL1CA11hCALL11RL{LShCS0L ) R198443A0
001SS L800 AP !S!0 Rh h1RY CLAPPL1CA11hCALL11RL{LShCS0L ) R198444AA
001SS L800 AP !S!1 Rh X11 CLAPPL1CA11hCALL11RL{LShCS0L ) R198444AA
001SS L800 AP 001 1P h1RY WR1101L R0{0004) F1LLA{18
R180033ALC
001SS 0R LS 0003 LSA1 X11 CAhChLK LLhL{) R180083!8
001SS 0R AP 001 1P X11 WR1101L K R0{00F4) F1LLA{00
R180033ALC
001SS 0R AP 001 1P h1RY WR1101L R0{0004) F1LLA{18
R180033ALC
001SS 0R AP 001 1P X11 WR1101L K R0{00F4) F1LLA{00
R180033ALC
001SS 0R AP !S!0 Rh h1RY CLAPPL1CA11hCALL11RL{LShCS0L ) R198443A0
001SS 0R LS 000! LSA1 h1RY CAhChL hLhAh1Kh{0000000L) R180098L00
001SS L800 LS 0003 LSA1 X11 CAhChLK R180098L00
Copyright (c) 2009, The Evans Group, nc. 69
Maximizing CPU Savings
CPU savings is maximized when no non-Threadsafe
commands are issued between the first SQL command and
the last
EXEC SQL OPEN CURSOR
PERFORM UNTL ...
EXEC SQL FETCH..
EXEC CCS WRTEQ TD
END-PERFORM
Copyright (c) 2009, The Evans Group, nc. 70
Maximizing CPU Savings
QR TCB
Task Starts
FETC
FETC
Open TCB
DB2 Code executes
WRITEQ TD
DB2 Code executes
WRITEQ TD
Copyright (c) 2009, The Evans Group, nc. 71
Maximizing CPU Savings
Once the command has been identified...
Replace it
Replace Transient Data with CCS TempStor?
Relocate it
Move the command outside of the SQL loop?
Copyright (c) 2009, The Evans Group, nc. 72
Maximizing CPU Savings
Replace Transient Data with CCS Temporary Storage:
EXEC SQL OPEN CURSOR
PERFORM UNTL ...
EXEC SQL FETCH..
EXEC CCS WRTEQ TS
END-PERFORM
Copyright (c) 2009, The Evans Group, nc. 73
Maximizing CPU Savings
DFH$MOLS of modified program running Threadsafe in
test
EXEC CCS WRTEQ TD replaced with WRTEQ TS
L!R0C1 00004!0 !0000
LSRL1SP1 000883390000013 00.00.08.89787 483
LSRCPL1 0003A4L30000013 00.00.03.8!084 483
SLSP11h 0000!S700000013 00.00.00.1S334 483
L1SPW11 000003C000001! 00.00.00.01SS8 48!
0RL1SP1 000008S400000141 00.00.00.0!S9! 3!1
0RCPL1 00000!100000141 00.00.00.0110! 3!1
KY8L1SP1 0008S9L3000000A1 00.00.08.8S937 181
KY8CPL1 0003A1F7000000A1 00.00.03.80913 181
L8CPL1 0003A1F7000000A1 00.00.03.80913 181
0RhLLLY 000003!L00000140 00.00.00.01300 3!0
LSChLLY 0000033C00000144 00.00.00.013!4 3!4
A ratio of .01
Copyright (c) 2009, The Evans Group, nc. 74
Maximizing CPU Savings
00188 0R LS 0003 LSA1 X11 CAhChLK LLhLhAh{0R) R19SA81!
00188 L800J LS 0003 LSA1 X11 CAhChLK R180098L00
00188 L800J AP !S!1 Rh X11 CLAPPL1CA11hCALL11RL{LShCS0L ) R19844!FA
00188 L800J AP 001 1P h1RY WR1101S R0{0004) F1LLA{18
R19844378
00188 L800J AP 001 1P X11 WR1101S K R0{00F4) F1LLA{00
R19844378
00188 L800J AP !S!0 Rh h1RY CLAPPL1CA11hCALL11RL{LShCS0L ) R19844484
00188 L800J AP !S!1 Rh X11 CLAPPL1CA11hCALL11RL{LShCS0L ) R19844484
00188 L800J AP !S!0 Rh h1RY CLAPPL1CA11hCALL11RL{LShCS0L ) R19844!FA
00188 L800J AP !S!1 Rh X11 CLAPPL1CA11hCALL11RL{LShCS0L ) R19844!FA
00188 L800J AP 001 1P h1RY WR1101S R0{0004) F1LLA{18
Copyright (c) 2009, The Evans Group, nc. 75
Maximizing CPU Savings
QR TCB
Task Starts
FETC
Open TCB
DB2 Code executes
WRITEQ TS
FETC
WRITEQ TS
Copyright (c) 2009, The Evans Group, nc. 76
Maximizing CPU Savings
Relocate Transient Data Writes:
XC S0L Ph CLRSR
PRFRh Lh11L ...
PRFRh vARY1hC.
XC S0L F1C..
hv RSLL1S 1 WSRSLL1S{)
hLPRFRh
PRFRh vARY1hC.
XC C1CS WR110 1L FRh{WSRSLL1S{))
hLPRFRh
hLPRFRh
Copyright (c) 2009, The Evans Group, nc. 77
Maximizing CPU Savings
DFH$MOLS of modified program running Threadsafe in test
Results of 10 SQL FETCH placed in Working Storage, then
issue 10 EXEC CCS WRTEQ TD at once
L!R0C1 00004!0 !0000
LSRL1SP1 000883390000013 00.00.08.89787 !81!
LSRCPL1 0003A4L30000013 00.00.03.8!084 !81!
SLSP11h 0000!S700000013 00.00.00.1S334 !81!
L1SPW11 000003C000001! 00.00.00.01SS8 !811
0RL1SP1 000008S400000141 00.00.00.0!S9! 10S!
0RCPL1 00000!100000141 00.00.00.0110! 10S!
KY8L1SP1 0008S9L3000000A1 00.00.08.8S937 S!8
KY8CPL1 0003A1F7000000A1 00.00.03.80913 S!8
L8CPL1 0003A1F7000000A1 00.00.03.80913 S!8
0RhLLLY 000003!L00000140 00.00.00.01300 10S0
LSChLLY 0000033C00000144 00.00.00.013!4 10SS
A ratio of .06
Copyright (c) 2009, The Evans Group, nc. 78
Maximizing CPU Savings
Example from GE Convert to Threadsafe followed by
program modification to minimize TCB switching
nitial threadsafe conversion yielded 12% savings; second phase
yields additional 20% for a total 36% reduction in CPU
Copyright (c) 2009, The Evans Group, nc. 79
Maximizing CPU Savings
Note:
CCS RC is not threadsafe. This means that threadsafe
commands that are function shipped will be treated as if
they are non-threadsafe.
Copyright (c) 2009, The Evans Group, nc. 80
Ensuring Threadsafe Coding When Creating New
Programs
Ensure threadsafe coding standards are met
Minimize number of TCB switches
Design is critical
Copyright (c) 2009, The Evans Group, nc. 81
Ensuring Threadsafe Coding When Creating New
Programs
Eliminate updates to shared storage areas:
CWA
GWA
GETMAN(SHARED)
OS GETMAN
LOAD HOLD
Require use of RENT on link-edit step
Use RENTPGM=PROTECT in CCS
Ensure ThreadsaIe Coding Standards
Copyright (c) 2009, The Evans Group, nc. 82
Ensuring Threadsafe Coding When Creating New
Programs
Maximum performance
Use only Threadsafe commands
Design program flow to cluster SQL calls
ssue non-Threadsafe commands before or after SQL
activity complete
Minimize number oI TCB switches
Copyright (c) 2009, The Evans Group, nc. 83
QR TCB
Task Starts
E.C. non-threadsaIe
E.C. non-threadsaIe
EXEC SQL
E.C. non-threadsaIe
Task Termination
Open TCB
DB2 Code executes
E.C. threadsaIe
E.C. threadsaIe
DB2 Code executes
E.C non-threadsaIe
Copyright (c) 2009, The Evans Group, nc. 84
Exploiting The OTE Without DB2
You can exploit the Open environment without DB2
For CCS 2.2 & 2.3, write a "dummy TRUE:
nclude OPENAP on the ENABLE command
The TRUE program must be defined as Threadsafe
See the CCS Customization Guide section on Task Related
User Exits
Copyright (c) 2009, The Evans Group, nc. 85
Exploiting The OTE Without DB2
Functions like DB2 call:
When task calls OPENAP true, spun to L8 TCB
f user program THREADSAFE, task remains on L8 until
forced off
No supported method to tell if task is on L8 or QR
#eview 7est7ictions defined in Customization Guide!
Copyright (c) 2009, The Evans Group, nc. 86
Exploiting The OTE Without DB2
You can exploit the Open environment without DB2
For CCS 3.1 and higher, use the OPENAP RDO parm:
Set AP PROGRAM parameter to OPENAP
The program must be Threadsafe
AII user code runs in the OTE environment
Copyright (c) 2009, The Evans Group, nc. 87
Exploiting The OTE Without DB2
Forces program to run on L8/9 TCB:
Program is initialized on L8 TCB if CCS key
Program is initialized on L9 TCB if USER key
f program issues non-threadsafe command, task is spun to
QR
Once command has completed, task is spun to L8/9
Use NQURE_CURRENT_PROGRAM and
NQURE_PROGRAM to identify
Copyright (c) 2009, The Evans Group, nc. 88
Exploiting The OTE Without DB2
There are performance issues for OPENAP programs that
issue non-Threadsafe commands:
L8000 AP 001 1P X11 C1hA1h K 00F4
L8000 AP 001 1P h1RY WR1101L 0004
L8000 LS 000! LSA1 h1RY CAhChL 0R
0R LS 0003 LSA1 X11 CAhChLK
0R LL 0301 LLL h1RY LCA1 1SLCL80.1SAAC7.LC1.CS
0R LL 030! LLL X11 LCA1K 18FF1S0 . C4C33CS
0R Sh 0301 ShCF h1RY C1hA1h 1SL3C0L4 . 00000018.1000.YS.KS
0R Sh 030! ShCF X11 C1hA1hK 00043000
0R AP F800 1LA h1RY WR111RAhS1h1LA1A CS.18FL30 . 00000001.YS
0R LL 0301 LLL h1RY LCA1 1SLCL80.00043388.LC1.CS
0R LL 030! LLL X11 LCA1K 18FF1S0 . C4C33CS
0R AP F801 1LA X11 WR111RAhS1h1LA1AK
0R LS 000! LSA1 h1RY CAhChL L8
L8000 LS 0003 LSA1 X11 CAhChLK
L8000 AP 001 1P X11 WR1101L K 00F4
L8000 AP 001 1P h1RY WR1101L 0004
L8000 LS 000! LSA1 h1RY CAhChL 0R
0R LS 0003 LSA1 X11 CAhChLK
Copyright (c) 2009, The Evans Group, nc. 89
Exploiting The OTE Without DB2
There are performance issue for USER key OPENAP
programs that access OPENAP TRUE (includes DB2)
USER key Program is initialized on L9 TCB
OPENAP TRUE is initialized on L8 TCB
When L9 program issues DFHRMCAL to OPENAP TRUE:
Task is spun to L8 TCB for duration of TRUE
Task is returned to L9 following completion of TRUE
Copyright (c) 2009, The Evans Group, nc. 90
OTE and TRUEs Scenarios for OPENAP TRUE
L9 TCB
Task Starts
EXEC SQL
E.C.WRITEQ TD
EXEC SQL
E.C. RETURN
L8 TCB
DB2 code executes
DB2 code complete
DB2 code executes
DB2 code complete
With OPENAPI program in USER key
QR TCB
WRITEQ TD starts
WRITEQ TD ends
Task termination
Copyright (c) 2009, The Evans Group, nc. 91
Exploiting The OTE Without DB2
L9000 AP !S!0 Rh h1RY CLAPPL1CA11hCALL11RL{LShCS0L )
L9000 Rh 0301 RhLh h1RY ALLL1hK Rh1.18F7L14 . 00000030 . 000000
L9000 Rh 030! RhLh X11 ALLL1hKK 0100000!.18F7L14 . 00000030 . 0
L9000 LS 000! LSA1 h1RY CAhChL 0000000L
L8000 LS 0003 LSA1 X11 CAhChLK
L8000 AP 3180 L!X1 h1RY APPL1CA11h R0LS1 XC S0L SLC1
L8000 AP 3!S0 L!L! h1RY L!AP1CALL 18FFC030
L8000 AP 3!S1 L!L! X11 L!AP1CALLK
L8000 AP 3181 L!X1 X11 APPL1CA11hR0LS1 S0LCL 0 R1LRhL h XC S0L S
L8000 Rh 0301 RhLh h1RY S1L1hK 0100000!.18F7L1C . 0000000L . 0
L8000 Rh 030! RhLh X11 S1L1hKK 18F7L1C . 0000000L . 00000008.
L8000 LS 000! LSA1 h1RY CAhChL 0000000C
L9000 LS 0003 LSA1 X11 CAhChLK
L9000 AP !S!1 Rh X11 CLAPPL1CA11hCALL11RL{LShCS0L )
Copyright (c) 2009, The Evans Group, nc. 92
Exploiting The OTE Without DB2
One restriction in OPENAP programs:
Do not attem5t to initiaIize batch LE envi7onment
unde7 CICS OPEAPI.
Copyright (c) 2009, The Evans Group, nc. 93
Exploiting The OTE Without DB2
XPLNK
New in CCS 3.1
For C/C++ programs compiled with XPLNK option
Functions as OPENAP program
Utilizes hybridized LE environment
Not quite batch
Copyright (c) 2009, The Evans Group, nc. 94
Futures
"t is the intention of BM for future releases of CCS
Transaction Server for z/OS to continue to enhance
OTE support to enable the ongoing migration of CCS
and application code from the QR to open TCBs.
Threadsafe considerations for CCS
Copyright (c) 2009, The Evans Group, nc. 95
Futures
BM committed to making more commands threadsafe
BM Announces additional threadsafe commands for
CCS 2.3, CCS 3.1 and CCS 3.2
CCS 3.2 introduces threadsafe file control (local)
Note, CCS TS 3.2 was shipped with threadsafe VSAM
disabled. Apply PK45354 to activate it
Copyright (c) 2009, The Evans Group, nc. 96
Recommendations
Consider Threadsafe implications now.
Heavy DB2 users receive greatest savings.
Don't forget purchased packages
Beware of COBOL calls (dynamic or static)
Copyright (c) 2009, The Evans Group, nc. 97
Recommendations
Convert XRMN/OUT and Dynamic Plan Selection exits
befo7e migrating to a threadsafe capable CCS release
Convert all frequently used exit programs to threadsafe
before converting programs
Verify that required maintenance is on CCS and vendor
products before converting programs to threadsafe
Review BM Redbook "Threadsafe Considerations for
CCS

Вам также может понравиться