® IBM Software Group © 2006 IBM Corporation Enterprise COBOL Education Using Rational Developer for System Z Enterprise COBOL Education Using Rational Developer for System Z Performance Optimization Performance Optimization Jon Sayles, IBM Software Group, Rational EcoSystems Team 2 IBM Trademarks and Copyrights © Copyright IBM Corporation 2007,2008, 2009. All rights reserved. The information contained in these materials is provided for informational purposes only, and is provided AS IS without warranty of any kind, express or implied. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, these materials. Nothing contained in these materials is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software. References in these materials to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates. This information is based on current IBM product plans and strategy, which are subject to change by IBM without notice. Product release dates and/or capabilities referenced in these materials may change at any time at IBM’s sole discretion based on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way. IBM, the IBM logo, the on-demand business logo, Rational, the Rational logo, and other IBM Rational products and services are trademarks or registered trademarks of the International Business Machines Corporation, in the United States, other countries or both. Other company, product, or service names may be trademarks or service marks of others. 3 Course Contributing Authors Thanks to the following individuals, for assisting with this course: Tom Ross, IBM/Rational Dave Myers, IBM/Rational 4 Purpose of This Document Course Name: COBOL Foundation Training - with RDz Course Description: Learn the COBOL language, RDz and learn z/OS terms, concepts and development skills in this course. Pre-requisites: Some experience in a 3rd or 4th Generation Language is expected. SQL is also recommended. Course Length: 10 days Topics (Agenda) Getting Started - installing and configuring RDz - and the course materials, and using Eclipse to edit COBOL COBOL General Language Rules Basic COBOL Statements Structured Programming Concepts and Coding Patterns Data - numeric and character - deep/dive Records and table handling - deep/dive Input/Output and Sequential File patterns Debugging Programs - Note: Deep dive on using RDz for common COBOL programming errors (001, 0C4, 0C7, infinite loops, fall-thru, etc.) COBOL Subprograms and the Linkage Section Advanced Character Manipulation COBOL Intrinsic Functions, Date and Time coding patterns, and Language Environment calls Reports and report writing patterns OS/390 Concepts and JCL (here's where the Sandbox/mainframe access starts) Compile/Link & Run Procs on the mainframe Indexed file Coding Patterns Sort/Merge and Master File Update Coding Patterns Accessing DB2 Data and Stored Procedures COBOL in the Real World: – CICS - lecture only – IMS (DL/I and TM) - ditto – Batch processing - ditto – Java calling COBOL – COBOL and XML Statements – SOA and COBOL - creating and calling Web Services – Web 2.0 using Rich UI 5 Course Details Audience This course is designed for application developers who have learned or programmed in a 3 rd or 4 th generation language – and who need to build leading- edge applications using COBOL and Rational Developer for System z. Prerequisites This course assumes that the student has a basic understanding and knowledge of software computing technologies, and general data processing terms, concepts and vocabulary. Knowledge of SQL (Structured Query Language) is assumed for database access is assumed as well. Basic PC and mouse-driven development skills, terms and concepts are also assumed. Note that we will be covering RDz's mainframe-editor-compliant function key idiom in this unit 6 Source of COBOL Optimization Strategies Virtually all of the information presented in this course on COBOL language and compiler optimization guidelines were drawn from IBM publication: The paper includes http://www-01.ibm.com/support/docview.wss?uid=swg27001475 authored by Rick Arellanes 7 At the end of this course, you will be able to: Discuss the general tuning options for COBOL Applications Define the trade-offs and functional characteristics of COBOL Compiler options that affect Run-time Performance Distinguish COBOL statements that are candidates for performance re-writes Re-code candidate COBOL statements into better performing code patterns Course Objectives 8 Course Using an Optimal Programming Style Using an Optimal Programming Style Choosing Efficient Datatypes Handling Tables Efficiently Compiler Options that Affect Run-time Performance Run-time Options that Affect Run-time Performance Efficient COBOL Coding Techniques Tuning CICS, IMS, DB2 and VSAM Access Appendices Units: Units: Compiler Directives Compiler Directives 9 The coding style you use can affect how the optimizer handles your code. You can improve optimization by using structured programming techniques, factoring expressions, using symbolic constants, and grouping constant and duplicate computations. Using structured programming Factoring expressions Using symbolic constants Grouping constant computations Grouping duplicate computations Unit Objectives 10 Tuning your program – 1 of 2 When a program is "well-structured", you can assess its performance. A program that has a tangled control flow is difficult to understand and maintain. The tangled control flow also inhibits the optimization of the code. Therefore, before you try to improve the performance directly, you need to assess certain aspects of your program: Examine the underlying algorithms for your program. For top performance, a sound algorithm is essential. For example, a sophisticated algorithm for sorting a million items can be hundreds of thousands times faster than a simple algorithm. Look at the data structures. They should be appropriate for the algorithm. When your program frequently accesses data, reduce the number of steps needed to access the data wherever possible. After you have improved the algorithms and data structures, look at other details of the COBOL source code that affect performance. You can write programs that result in better generated code sequences and use system services better. [...]... Options that Affect Run-time Performance Run-time Options that Affect Run-time Performance Efficient COBOL Coding Techniques Appendices 35 Unit Objectives At the end of this course, you will be able to: Discuss the general tuning options for COBOL Applications Define the trade-offs and functional characteristics of COBOL Compiler options that affect Run-time Performance 36 ... Compiler Directives Units: Using an Optimal Programming Style Choosing Efficient Datatypes Handling Tables Efficiently Compiler Options that Affect Run-time Performance Run-time Options that Affect Run-time Performance Efficient COBOL Coding Techniques Appendices 25 Table Elements – 1 of 4 A table element has a collective name, but the individual items within it do not have unique data-names... a length of 2 characters 31 Workshop – Proving out the theory In the last three sections you have ingested quite a # of "Best Practices" for COBOL optimization Wouldn't it be nice to actually see whether or not making certain changes to a program improved performance? Our bet… yes On the next few slides are steps for you to run a program that contains use cases as isolated variable in just such... can improve optimization by using structured programming techniques, factoring expressions, using symbolic constants, and grouping constant and duplicate computations 16 Course Compiler Directives Units: Using an Optimal Programming Style Choosing Efficient Datatypes Handling Tables Efficiently Compiler Options that Affect Run-time Performance Run-time Options that Affect Run-time Performance. ..Tuning your program – 2 of 2 The following areas affect program performance: Coding techniques These include using a programming style that helps the optimizer, choosing efficient data types, and handling tables efficiently Optimization You can optimize your code by using the OPTIMIZE compiler option Compiler options and USE FOR DEBUGGING... used for computations Consistent data types can reduce the need for conversions during operations on data items Making code significantly more efficient at run-time You can also improve program performance by carefully determining when to use fixed-point and floating-point data types 18 Choosing efficient computational data items – 1 of 2 When you use a data item mainly for arithmetic or as... decimal data Note that this is especially important for integer math, and not as hard and fast a rule for decimal computations, although USAGE DISPLAY data is almost always less efficient for doing math in COBOL If a fixed-point arithmetic statement has intermediate results with a large precision (number of significant digits), the compiler uses decimal arithmetic anyway, after converting the operands... or fewer digits Above 18 digits, the compiler always uses decimal arithmetic With a precision of nine to 18 digits, the compiler uses either form Generally More Efficient Generally Less Efficient COBOL Math Variable Type "Efficiency-o-meter" USAGE BINARY (COMP) USAGE PACKED DECIMAL (COMP-3) 19 USAGE DISPLAY Choosing efficient computational data items – 2 of 2 To produce the most efficient code... should ensure that two numbers to be compared, added, or subtracted not only have the same usage but also the same number of decimal places (9s after the V in the PICTURE clause) This means that, for COBOL work areas in the DATA DIVISION – (not file and database buffers) – ensure consistent PIC clauses as follows: Change this to this: 21 Making floating point arithmetic expressions efficient Computation... program If you pass a data item to a subprogram BY REFERENCE, the optimizer REFERENCE treats it as an external data item and assumes that it is changed at every subprogram call CALL … BY REFERENCE is the COBOL language default Moral: If you know that you are passing immutable values from one program to the next in a CALL statement, pass them by value If you move a literal to a data item, the optimizer . Corporation Enterprise COBOL Education Using Rational Developer for System Z Enterprise COBOL Education Using Rational Developer for System Z Performance Optimization Performance Optimization Jon. COBOL Applications Define the trade-offs and functional characteristics of COBOL Compiler options that affect Run-time Performance Distinguish COBOL statements that are candidates for performance. key idiom in this unit 6 Source of COBOL Optimization Strategies Virtually all of the information presented in this course on COBOL language and compiler optimization guidelines were drawn