Key Takeaways: Performance Tuning

  1. Measure before you optimize. Use profiling tools (Strobe, SMF records) to identify actual bottlenecks. Developer intuition about performance is frequently wrong.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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.

  8. 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.

  9. 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.

  10. 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.