IBM Support

COBOL Performance Issue with READ INTO of Variable length record File

Troubleshooting


Problem

The performance numbers will vary depending on the record size, variation and distribution. There may be slow performance using READ...INTO coding. The situation evaluated involved a Variable Blocked QSAM file where there was a large variation in the size of the records. RECFM=VB. In the case described, the variable file contained records varying from around 250 bytes to 30,000 bytes with the majority around 250 bytes.

Symptom

The test programs run did only a READ and no processing vs a READ .... INTO a 30,000 byte work area.
The READ .... INTO version took 800%-1000% more CPU time with similar increases in clock time.

Here is a sample of the READ ... INTO code involved:
FD  INPUT-FILE
    BLOCK CONTAINS 0 RECORDS
    RECORD IS VARYING IN SIZE FROM 100 to 30000.
01  INPUT-REC    PIC X(30000).
01  INPUT-REC100 PIC X(100).
01  INPUT-REC250 PIC X(250).
    (etc. or a PIC X OCCURS.... )
WORKING-STORAGE SECTION.
01  WS-AREA  PIC X(30000).
             .......
PROCEDURE DIVISION.
             ....
    READ INPUT-FILE INFO WS-AREA AT END

Cause

If a 250 byte record is read, the length is captured and the READ....INTO moves 250 bytes from the file buffer to the work area. Then the remainder of the work area is padded with blanks, consuming CPU cycles.

Resolving The Problem

Modify as follows:
FD  INPUT-FILE
    BLOCK CONTAINS 0 RECORDS
    RECORD IS VARYING IN SIZE FROM 100 to 30000
    DEPENDING ON REC-LEN.
01  INPUT-REC    PIC X(30000).
01  INPUT-REC100 PIC X(100).
01  INPUT-REC250 PIC X(250).
    (etc. or a PIC X OCCURS.... )
WORKING-STORAGE SECTION.
01  WS-AREA  PIC X(30000).
01  REC-LEN  PIC 9(5) COMP.
             .......
PROCEDURE DIVISION.
             ....
    READ INPUT-FILE AT END .......
    MOVE INPUT-REC(1:REC-LEN) TO
           WS-AREA (1:REC-LEN).


REC-LEN will be set to the length of each record when it is read.
By using the length of the data read, then coding with the Reference Modification (1:REC-LEN) for both the MOVE from and to fields will restrict the number of bytes moved from the buffer to the correct record size and prevent the padding of the entire unused part of the work area.
The READ....INTO took about 700-800% more CPU cycles than this method in the test environment..

However, if the variable input file contains records that are all similar in size to the work area, then READ INTO would not experience the performance situation described above.

Also see technote
http://www.ibm.com/support/docview.wss?uid=swg21242182
for additional hints on working with variable blocked files.

[{"Product":{"code":"SS6SG3","label":"Enterprise COBOL for z\/OS"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"--","Platform":[{"code":"PF035","label":"z\/OS"}],"Version":"3.4;4.1;4.2","Edition":"","Line of Business":{"code":"LOB17","label":"Mainframe TPS"}}]

Document Information

Modified date:
08 August 2018

UID

swg21515326