Friday, 26 July 2013

10 Simple (But Important) Things To Remember About COBOL Performance Tuning. | Mainframe-Forum.

In today's,  tutorial I will discuss why mainframe optimization techniques (i.e. Mainframe Application Performance Tuning) is the most trending topic in the IT industry. Year on year companies of investing heavenly on programmer skills and also stress more on optimizing existing Mainframe Application.  

As you all know that Legacy Application is an extremely secure, robust, reliable, and scalable system among all existing computing platforms. The only drawback with the Mainframe Application is high maintenance and running costs. But eventually, that cost can be reduced by Mainframe MIPS optimization which can be achieved by optimizing new and existing COBOL, JCL, COBOL-DB2, COBOL-CICS programs.

Legacy Application optimization.
10 Simple (But Important) Things To Remember About COBOL Performance Tuning.


In my opinion, the application running cost is directly impacted by how the system is designed and business logic is written in underlying programs. A badly designed or non-optimized system will tend to consume more Mainframe MIPS as compare to the optimized legacy applications. 

In my past experience, I have seen a lot of COBOL, COBOL-DB2, COBOL-CICS programs that were poorly designed either due to lack of programming skill or may be due to the scarcity of time. There could be n number of reasons, but being a programmer I feel that it's the responsibility of a designer and COBOL programmer to write robust, compact, readable and defect-free code. 


db2 query optimization tools
COBOL Performance Tuning.

In my entire career, I have written many COBOL, COBOL-CICS, COBOL-DB2 programs and I always follow the below set of rules to ensure that my COBOL code compact, readable, and highly optimized from a performance perspective. Thus with the help of COBOL performance tuning tips, you can achieve Mainframe MIPS Optimization.

Tip # 1

Don't jump to write code. Being a programmer you should spend some time understanding the requirement. Precisely, prepare a list of functions (example - date calculation, etc.) that you will be using in your program.

Based on requirements decide if you need a single program or multiple programs. In case you have a common calculation that is used by multiple modules then you should include common logic in COBOL COPYBOOK or maybe in subprogram to avoid duplication of code and for better CODE maintainability.  

Tip # 2

To estimate the number of records that your COBOL program is expected to handle. It provides a rough idea about the number of I/O (Input/Output) operations your program is expected to perform. Based on available details you can decide which is a suitable medium to store data i.e. Flat File, VSAM Cluster, or DB2 table. However, the scope is limited due to the project requirements.

Tip # 3

Be careful while selecting Working Storage Variables (i.e. temporary variables) and their datatype. Always, use S in the Picture for all numeric fields of all usages unless you want the sign to be stripped from the number. Use an odd number of digits in all fields with Packed-Decimal usage. For example, I used numeric datatype with usage as COMP-3 for the counter variable. It would help you in saving storage space.

Similarly, use COMP for temporary variables which is used for numerical calculation, because arithmetic operation on binary variables is faster as compared to other data types.

Avoid, unnecessary movement of data from one variable to other temporary variables, I have seen many programs where programmers read data from the file and store an entire record into working storage variables for further processing. In my opinion, you should read the record and move only the selected variable which is required for calculation despite moving the entire record.


Tip # 4


Initialized all COPYBOOKS and other working storage variables at the beginning of core program logic. Do not use COBOL Initialized verb in the middle of program logic again and again for initializing COPYBOOKS and working storage variables. You should always prefer the COBOL VALUE Clause to initialize working storage variables. Also, you can store initialized value in some working storage variables and use the COBOL MOVE statement or COBOL INITIALIZE statement to re-initialized variables whenever that is required.

Never use COBOL INITIALIZE Initialize statements to initialize big COBOL table structures (i.e. variables) or record descriptions that are not required to be initialized. For example, you carelessly initialize a 900,000-byte table that doesn’t need to be initialized, you slow the performance of the program for no reason. 

Tip # 5


You’ll probably agree that it’s usually better to use an Evaluate statement than nested If statements whenever you get three or more levels deep.

Do not use the IF-ELSE statement more than three nested levels, because the execution of the IF-ELSE statement consumes a lot of CPU. Try to replace Nested-Ifs with COBOL EVALUATE which is better than nested-Ifs in terms of performance.

It's always advisable to properly align the Else and End-If with the related If. Remember that the compiler always pairs an Else clause and an End-If with the first unpaired If that precedes it, no matter how the code is indented.


Tip # 6


Never use COBOL internal SORT or COBOL MERGE statement in the COBOL program until it is absolutely required. My recommendation is to used the JCL SORT utility to sort or merge data into the desired order.  

Tip # 7

When you code a compound condition in an If, Perform Until, or Evaluate statement, use indentation to align the parts of the condition that are connected by AND or OR whenever that will make the condition easier to interpret. Use parentheses to clarify how a compound condition should be interpreted. Avoid the use of implied subjects or operators whenever there’s a chance for confusion.

Tip # 8

Mainframe Compiler Optimization (i.e. COBOL compiler option) is another important factor that you should always keep in mind. The DYNAM, FASTSRT, NUMPROC, OPTIMIZE, RENT, SSRANGE, TEST, and TRUNC compiler options can all affect run-time performance.

Performance consideration: SSRANGE can degrade the performance of your program somewhat because of the extra overhead to check each subscripted or indexed item.

Tip # 9

Use the COBOL Inline Perform when it allows you to combine two parts of a single function in the same procedure. Don’t use the inline Perform to combine two functions in a single procedure. Remember that the goal of structured design is to divide a large program up into manageable modules with one function in each module. 

Tip # 10

Error handling, your program logic should have logic to handle all possible error codes, while reading writing data to a file or to a BD2 table.

Tip # 11

Always, use condition names for all switches and flags because they make a program easier to understand and you must use the Set to True statement to turn on switches and flag conditions.

Tip # 12

For COBOL-DB2 programs, you should commit records to the database as per your company/project standards and commit data on a regular interval.

Similarly, for COBOL-IMS you should release buffers at regular intervals to avoid buffer overflow.

Last but not least, you should use your company/project coding guidelines/standards for structured programming along with above mention mainframe optimization techniques and mainframe compiler optimization techniques.


Looking for a job? Check out our Top 100 Interview Questions and Answers.



Conclusion. 

Finally, this marks an end to our today's COBOL Performace Tips. In this session, you learn many different tips which are simple but very effective in saving overall application running cost. A mainframe is all about cost and your legacy application must be optimized to reduce overall application running cost. Do join us for the next tutorial in CA7 Command reference.

►Subscribe to Topictrick & Don't forget to press THE BELL ICON to never miss any updates. Also, Please visit mention the link below to stay connected with Topictrick and the Mainframe forum on - 

► Youtube
► Facebook 
► Reddit

Thank you for your support. 
Mainframe Forum™

COBOL Performance Tuning
Mainframe-Forum


No comments:

Post a Comment

New In-feed ads