Key Takeaways: Performance Tuning
-
Measure before you optimize. Use profiling tools (Strobe, SMF records) to identify actual bottlenecks. Developer intuition about performance is frequently wrong.
-
I/O dominates most COBOL batch programs. 80-95% of elapsed time is typically spent waiting for I/O. Optimize I/O first for maximum impact.
-
Block size is the single most impactful I/O optimization. Increasing block size from LRECL to 32,000 bytes can reduce I/O operations by 40x or more — often with a one-line JCL change.
-
Use COMP-3 or COMP for arithmetic fields. DISPLAY arithmetic is 3-5x slower because the CPU must convert between character and numeric formats. This matters in programs performing millions of calculations.
-
SEARCH ALL (binary search) is essential for large tables. For a 10,000-entry table, binary search is 357x faster than linear search. Always use SEARCH ALL for tables over 50 entries.
-
Compiler options provide free performance. OPTIMIZE(FULL), NUMPROC(PFD), and TRUNC(OPT) can improve CPU performance by 10-30% with zero code changes — but understand the trade-offs.
-
Eliminate SQL in loops. A single JOIN query can replace thousands of individual SELECT statements. Multi-row FETCH reduces DB2 overhead by factors of 100x.
-
Caching exploits skewed access patterns. When 80% of lookups hit the top N entries, an in-memory cache can eliminate 80%+ of I/O operations.
-
Sort before process. Sorting a transaction file by master file key converts random I/O to sequential I/O, which can be 10-100x faster due to buffering.
-
Performance degrades over time. Data volumes grow, new features add processing, and batch windows don't expand. Regular profiling catches degradation before it causes production incidents.