Accounting for processor usage in a CICS DB2 environment

Information about processor time consumption is provided in the DB2® accounting and statistics trace records. You can use these records to calculate the total processor time used in CICS® and DB2.

The DB2 accounting trace can be started with CLASS 1, CLASS 2, or CLASS 3. However, CLASS 1 must always be active to externalize the information collected by activating CLASS 2, CLASS 3, or both classes.

The processor times reported in the DB2 accounting records are the TCB time for the thread TCB running code in CICS or in the DB2 address space, using cross-memory services; and the SRB time for work scheduled in CICS.

CLASS 1 (the default) results in accounting data being accumulated by several DB2 components during normal execution. This data is then collected to write the DB2 accounting record. The data collection does not involve any overhead of individual event tracing.

CLASS 2 and CLASS 3 activate many additional trace points. Every occurrence of these events is traced internally, but is not written to an external destination. Rather, the accounting facility uses these traces to compute the additional total statistics that appear in the accounting record when CLASS 2 or CLASS 3 is activated. Accounting CLASS 1 must be active to externalize the information.

CLASS 2 collects the delta elapsed and processor times spent 'IN DB2' and records this in the accounting record.

CLASS 3 collects the I/O elapsed time and lock and latch suspension time spent 'IN DB2' and records this in the accounting record.

CLASS 7 and CLASS 8 in DB2 collect package level accounting in DB2 and package level accounting wait in DB2. For information on package level accounting, refer to the DB2 for z/OS: Application Programming Guide and Reference for Java.

The statistics trace reports processor time in the statistics records. The processor times reported are:
  • Time under a DB2 address space TCB running asynchronous of the CICS address space. Examples of this are the DB2 log and writes from the buffer pools.
  • Time under SRBs scheduled under the DB2 address spaces. An example is the asynchronous read engine for sequential prefetch.
The DB2 address spaces reported in the statistics record are:
  • Database manager address space
  • System services address space
  • IRLM.
In a CICS DB2 environment, the processor time from the DB2 accounting records is typically much greater than the processor time reported in the DB2 statistical records, because most of the processor time used is in the thread TCB itself and in the DB2 address spaces using cross memory services.

DB2 accounting records are produced when a thread is terminated or signon occurs. This means that the period reported in the DB2 accounting record is the time between thread start or user signon (if reusing a thread previously used by another user) and thread termination or another signon. If several different transactions are specified for the same DB2ENTRY, and they use the same CICS transaction ID and the same DB2 authorization ID to sign on to the thread, then the DB2 accounting record for this thread can include data for more than one transaction. Also, if a transaction releases its DB2 thread at syncpoint, and the thread is terminated or re-used by another transaction, then the original transaction has to use a different thread. A single transaction can therefore be associated with multiple DB2 threads during the life of its execution. As DB2 produces accounting records for each thread, this can mean that multiple accounting records are produced for the transaction. See Controlling the relationship between DB2 accounting records and CICS performance class records for information on how you can determine the transactions that are included in each DB2 accounting record.

The processor time is accurately obtainable by authorization ID within the transaction by aggregating all the accounting records for this authorization ID and transaction. Note, however, that the elapsed times associated with the accounting record would be of little value in this case, because the sum of the elapsed times does not include the time from one commit point to the first SQL call in the next UOW. The elapsed time for a thread is associated with the thread and not with the transaction.

Figure 1 and Figure 2 show each period of processor time that is reported by CICS and DB2, and where it takes place. The location of processing differs depending on whether or not the application accessing DB2 is threadsafe. This is because when CICS is connected to DB2, and is exploiting the open transaction environment, the CICS DB2 attachment facility uses CICS-managed open TCBs rather than CICS DB2 subtask TCBs.

Figure 1 shows the situation when CICS is connected to DB2 and the application accessing DB2 is not threadsafe.
Figure 1. CICS with DB2 and non-threadsafe application: Processor times recorded
Processing is carried out in the CICS address space and in the DB2 address space. In the CICS address space, processing is carried out on either the CICS main TCB, or a thread TCB that controls the thread into DB2. In the example, processing begins on the CICS main TCB, then moves to a thread TCB. It then moves into the DB2 address space, and then back to the thread TCB. From the thread TCB, processing moves back to the CICS main TCB. After some time on the CICS main TCB, processing moves to a thread TCB again, then into the DB2 address space, then back to the thread TCB, then back to the CICS main TCB again. The sequence is repeated once more, and processing finishes up on the CICS main TCB. This represents a total of three accesses to DB2, and from this process, ten different periods of processor time are reported. Time 1 is when processing is on the CICS main TCB, at the start of the example. For the first access to DB2, Time 2 is the time spent in the DB2 address space. Time 3 is the processor time from when processing moves to the thread TCB, to when it moves off the thread TCB to return to the CICS main TCB. Time 2 is therefore nested within Time 3: Time 3 includes all the processor time for which CICS has assigned the task to the thread TCB, even though some of the processing activity (Time 2) is taking place in the DB2 address space. Time 4 is the time when processing is back on the main CICS TCB. The remaining two repeats of the sequence are numbered as follows. For the second access to DB2, Time 5, in the DB2 address space; Time 6, on the thread TCB; Time 7, back in the CICS main TCB. For the third access to DB2, Time 8, in the DB2 address space; Time 9, on the thread TCB; Time 10, back in the CICS main TCB. The processor times are reported as in the text that follows, which is embedded within this figure.

This picture shows the environment when CICS is connected
to DB2 when the application
accessing DB2 is not threadsafe.

Times 3 + 6 + 9 are reported as CLASS 1 processor time
(time spent under the thread TCB)
Times 2 + 5 + 8 are reported as CLASS 2 processor time
(time spent in DB2)
Times 1 + 4 + 7 + 10 are reported as CICS processor time
(time spent on the CICS main TCB)

If CICS is connected to DB2 but the application accessing DB2 is not threadsafe, then CICS is using an open TCB to run the thread into DB2, but it is using the open TCB in the same way as it would use a subtask TCB. The TCB that CICS uses to run the thread into DB2 is called the thread TCB.
The periods of processor time shown in the figure are as follows:
  • Time 1: The application starts on the CICS main TCB. At the end of Time 1, the application issues an EXEC SQL request.
  • Time 2: DB2 is fulfilling the application's request. This processor time is spent in the DB2 address space. At the end of Time 2, DB2 passes its response to the CICS DB2 attachment facility.
  • Time 3: The CICS DB2 attachment facility is carrying out processing on the thread TCB. This covers both the processing needed for the application to access DB2, and the processing needed to pass DB2's response back to the application. It also includes the processor time taken for DB2 to fulfil the request and respond. Time 2 is therefore nested within Time 3. At the end of Time 3, DB2's response is passed to the application, and the access to DB2 is complete.
  • Time 4: The application has finished with DB2 for the moment. The application code runs on the CICS main TCB, until the application needs to access DB2 again. At the end of Time 4, the application issues a second EXEC SQL request.
  • Time 5: As for Time 2, DB2 is fulfilling the second request from the application.
  • Time 6: The CICS DB2 attachment facility is carrying out processing on the thread TCB related to this second request, or waiting for a response from DB2.
  • Time 7: The application code runs again on the CICS main TCB. It issues a third EXEC SQL request.
  • Time 8: As for Time 2, DB2 is fulfilling a third request from the application.
  • Time 9: The CICS DB2 attachment facility is carrying out processing on the thread TCB related to this third request, or waiting for a response from DB2.
  • Time 10: The application has now made all its EXEC SQL requests. The application code continues to run on the CICS main TCB until it terminates.
Figure 2 shows the situation when CICS is connected to DB2 and the application accessing DB2 is threadsafe.
Figure 2. CICS with DB2 and threadsafe application: Processor times recorded
Processing is carried out in the CICS address space and in the DB2 address space. In the CICS address space, processing is carried out on either the CICS main TCB, or an open TCB that controls the thread into DB2. In the example, processing begins on the CICS main TCB, then moves to the open TCB. It then moves into the DB2 address space, and then back to the open TCB. As the open TCB can run the application code, processing does not now move back to the CICS main TCB, but remains on the open TCB. Processing moves into the DB2 address space twice more, returning to the open TCB each time. Finally, when the task is complete, processing finishes up on the CICS main TCB. This represents a total of three accesses to DB2, and from this process, ten different periods of processor time are reported. Time 1 is when processing is on the CICS main TCB, at the start of the example. For the first access to DB2, Time 2 is the time spent in the DB2 address space. Time 3 is the processor time from when processing first moves to the open TCB, to when it finishes processing the DB2 access and recommences application code, still on the open TCB. Time 2 is therefore nested within Time 3: Time 3 includes all the processor time for which CICS has assigned the task to the thread TCB, even though some of the processing activity (Time 2) is taking place in the DB2 address space. Time 4 is the time when the open TCB is running application code before the next DB2 access. The remaining two repeats of the sequence are numbered as follows. For the second access to DB2, Time 5, in the DB2 address space; Time 6, on the open TCB processing the DB2 access; Time 7, still on the thread TCB but processing application code. For the third access to DB2, Time 8, in the DB2 address space; Time 9, on the open TCB processing the DB2 access; Time 10, moving back to the CICS main TCB, as the task is complete. The processor times are reported as in the text that follows, which is embedded within this figure.

This picture shows the environment when CICS is connected to DB2,
and when the application accessing DB2 is threadsafe.

Times 3 + 4 + 6 + 7 + 9 + 10 are reported as CLASS 1 processor time
(time spent under the open TCB, processing access to DB2
and running application code)
Times 2 + 5 + 8 are reported as CLASS 2 processor time
(time spent in DB2)
Times 1 + 11 are reported as CICS processor time
(time spent on the CICS main TCB)

Here, CICS is using an open TCB to run the thread into DB2. As the application is threadsafe, the application code can also run on the open TCB. The periods of processor time shown in the figure are as follows:
  • Time 1: The application starts on the CICS main TCB. At the end of Time 1, the application issues an EXEC SQL request.
  • Time 2: DB2 is fulfilling the application's request. This processor time is spent in the DB2 address space. At the end of Time 2, DB2 passes its response to the CICS DB2 attachment facility.
  • Time 3: The CICS DB2 attachment facility is carrying out processing on the thread TCB. This covers both the processing needed for the application to access DB2, and the processing needed to pass DB2's response back to the application. It also includes the processor time taken for DB2 to fulfil the request and respond. Time 2 is therefore nested within Time 3. At the end of Time 3, DB2's response is passed to the application, and the access to DB2 is complete.
  • Time 4: The application has finished with DB2 for the moment. As the application is threadsafe, the application code now runs on the thread TCB (the open TCB). At the end of Time 4, the application issues a second EXEC SQL request.
  • Time 5: As for Time 2, DB2 is fulfilling the second request from the application.
  • Time 6: The CICS DB2 attachment facility is carrying out processing on the thread TCB related to this second request, or waiting for a response from DB2.
  • Time 7: The application code runs again on the thread TCB. It issues a third EXEC SQL request.
  • Time 8: As for Time 2, DB2 is fulfilling a third request from the application.
  • Time 9: The CICS DB2 attachment facility is carrying out processing on the thread TCB related to this third request, or waiting for a response from DB2.
  • Time 10: The application has now made all its EXEC SQL requests. The application code runs again on the thread TCB.
  • Time 11: The application has completed its processing. The application terminates, and processing returns to the CICS main TCB.
Note that an application that is defined as threadsafe (that is, you have told CICS that the application code is threadsafe), can still issue CICS commands that are not threadsafe. These commands force a switch back to the CICS main TCB, and the application code then continues to run on the CICS main TCB until the application makes its next EXEC SQL request. The activity associated with the non-threadsafe CICS command, and with the application code that runs on the CICS main TCB, is reported as CICS processor time, and not as CLASS 1 processor time. Once the EXEC SQL request is issued, the application code can run on the open TCB again, and is reported from then on as CLASS 1 processor time.


dfhtk1a.html | Timestamp icon Last updated: Sunday, 4 June 2017