Sunday 11 August 2013

COBOL Efficient Coding Techniques Part - 1.

Coding Technique is one of the most important factor that can fine tune application performace. Eventially it individual program performace that contribute toward entire application performace. When program is desgin efficently running cost would be low for entire project.
This section focuses on how the source code can be modified to tune a program for better performance. Coding style, as well as data types, can have a significant impact on the performance of an application.
Producing higher performing code usually has a far greater impact than that of tuning the application via compiler and run-time options, but producing such code may not be a viable option for many existing applications since it does require modifying the source code and at times may even require an extensive knowledge of how the program works. However, these techniques should be considered for all new applications.
  • Data Files : Planning how the files will be created and used is an important factor in determining efficient file characteristics for the application. Some of the characteristics that affect the performance of file processing are: file organization, access method, record format, and blocksize. Some of these are discussed in more detail below.
QSAM Files : When using QSAM files, use large block sizes whenever possible by using the BLOCK CONTAINS clause on your file definitions (the default with COBOL is to use unblocked files). If you are using DFP Version 3 Release 1 or later, you can have the system determine the optimal blocksize for you by specifying the BLOCK CONTAINS 0 clause for any new files that you are creating and omitting the BLKSIZE parameter in your JCL for these files. This should significantly improve the file processing time (both in CPU time and elapsed time). 
Additionally, increasing the number of I/O buffers for heavy I/O jobs can improve both the CPU and elapsed time performance, at the expense of using more storage. This can be accomplished by using the BUFNO subparameter of the DCB parameter in the JCL or by using the RESERVE clause of the SELECT statement in the FILE-CONTROL paragraph. Note that if you do not use either the BUFNO subparameter or the RESERVE clause, the system default will be used.
Variable-Length Files : When writing to variable-length blocked sequential files, use the APPLY WRITE-ONLY clause for the file or use the AWO compiler option. This reduces the number of calls to Data Management Services to handle the I/Os. For performance considerations using the APPLY-WRITE-ONLY clause or the AWO compiler option.
VSAM Files : When using VSAM files, increase the number of data buffers (BUFND) for sequential access or index buffers (BUFNI) for random access. Also, select a control interval size (CISZ) that is appropriate for the application. A smaller CISZ results in faster retrieval for random processing at the expense of inserts, whereas a larger CISZ is more efficient for sequential processing.
 In general, using large CI and buffer space VSAM parameters may help to improve the performance of the application. In general, sequential access is the most efficient, dynamic access the next, and random access is the least efficient. 
However, for relative record VSAM (ORGANIZATION IS RELATIVE), using ACCESS IS DYNAMIC when reading each record in a random order can be slower than using ACCESS IS RANDOM, since VSAM may prefetch multiple tracks of data when using ACCESS IS DYNAMIC. 
ACCESS IS DYNAMIC is optimal when reading one record in a random order and then reading several subsequent records sequentially.
Random access results in an increase in I/O activity because VSAM must access the index for each request. If you use alternate indexes, it is more efficient to use the Access Method Services to build them than to use the AIXBLD run-time option. 
Avoid using multiple alternate indexes when possible since updates will have to be applied through the primary paths and reflected through the multiple alternate paths.


Created with Artisteer

No comments:

Post a Comment

New In-feed ads