Easytrieve CPU Optimization

CPU seconds drive mainframe software charges and batch window length. Easytrieve hides much complexity behind automatic file handling and report formatting, but that automation still executes machine instructions on every row. Broadcom's efficiency guidance focuses on data types in hot paths, array indexing, sort discipline, and intelligent table access. This page translates those recommendations into actionable habits for developers maintaining legacy reports and new extracts alike—without premature micro-optimization of cold code paths.

Progress0 of 0 lessons

Find CPU Hotspots Before Changing Code

Start with job accounting: SMF records or scheduler reports showing CPU versus wait. If CPU is high with low wait, suspect sort, arithmetic loops, or report formatting. If wait dominates, tune I/O first. Easytrieve does not ship a developer profiler in every installation, so use structured experiments—disable one REPORT, halve input with SELECT, or replace SEQUENCE with presorted input—and compare CPU deltas.

Binary Versus Zoned Numeric Fields

Mainframe binary packed fields (type B or P in definitions) align with hardware decimal instructions. Zoned decimal (type Z) suits display-friendly files but costs more when used in tight ADD and MULT loops. Define file fields to match source data, but convert to binary working storage for accumulators touched millions of times. Avoid repeated MOVE between zoned and packed in inner loops—convert once per row in BEFORE-LINE or JOB logic.

text
1
2
3
4
5
6
7
8
FILE SALES FB(80 800) AMOUNT-Z 40 7 Z 2 %SALES WS-TOTAL W 9 P 2 JOB INPUT SALES MOVE AMOUNT-Z TO WS-AMOUNT-P ADD WS-AMOUNT-P TO WS-TOTAL PRINT SALESRPT

Indexes Versus Subscripts in Arrays

When processing OCCURS tables or byte arrays, indexes (computed once) beat subscripts (converted internally each reference) in CPU-sensitive loops. Subscripts remain readable for small utilities; hot paths in payroll tax arrays or rate tables benefit from index variables updated explicitly in DO loops. Balance readability with measured cost.

Sort and SEQUENCE Discipline

Broadcom best practices recommend keeping masters presorted and avoiding redundant sorts during execution. Merge presorted updates in the same order as the master. Use one SORT activity to feed multiple PRINT statements when keys match. Filter with SELECT before SORT so the sort product compares fewer records. For installation sort, FASTSRT may reduce I/O wait inside sort when supported—coordinate with operations rather than coding it in application source.

Table SEARCH and Keyed Access

Large TABLE scans are O(n) per lookup. Indexed TABLE files where SEARCH ARG equals the key compile toward keyed READ semantics—far cheaper at scale. When lookups exceed a few thousand entries, evaluate VSAM KSDS instead of TABLE entirely. CPU and memory improve together.

CPU-focused tactics
TacticCPU effectNote
Binary accumulatorsLower per arithmetic opConvert at row boundary
Index in loopsLower array accessHot paths only
SELECT filterFewer ops overallValidate business rules
One shared sortAvoid duplicate sortMatch keys exactly
Keyed SEARCHAvoid table scanRequires indexed TABLE

Procedure and Macro Maintainability

Copy-pasted PROC blocks drift over years—one copy gains an extra SORT or DISPLAY during a panic fix. Central macros for FILE layouts and standard totals reduce accidental CPU regressions during maintenance even though macro expansion itself is not a runtime optimization. Code review checklists should flag new SORT, SEQUENCE, and DISPLAY in production branches.

Development PARM Overhead

DEBUG FLDCHK, FLOW, and verbose LIST options add CPU and storage during test. Remove them from production PARM profiles. ABEXIT SNAP is for diagnosis, not steady-state schedules. Production should follow site defaults unless operations approves exceptions.

Explain It Like I'm Five

CPU is how hard the computer thinks. Sorting a whole toy box every time you need one color is exhausting—that is SEQUENCE on already messy data. Counting with fast finger tricks (binary math) beats counting on slow sticky notes (zoned fields) when you add thousands of numbers. Ask the computer to do less work by giving it fewer toys and sorting once.

Exercises

  1. Identify one zoned field used in a loop and plan a packed working-storage accumulator.
  2. Count SORT and SEQUENCE statements in a legacy program; propose one consolidation.
  3. Explain FASTSRT to a teammate and who enables it at your site.
  4. Rewrite a table scan as keyed SEARCH when ARG matches the table key.

Quiz

Test Your Knowledge

1. For heavily used calculations Broadcom recommends:

  • Binary fields rather than zoned decimal
  • Character fields only
  • DISPLAY on every iteration
  • TABLE INSTREAM for all masters

2. Indexes compared with subscripts in array loops:

  • Produce more efficient code because subscripts must be converted internally
  • Are always slower
  • Apply only to SCREEN maps
  • Replace EOF tests

3. Sorting during Easytrieve execution:

  • Significantly increases CPU overhead per Broadcom best practices
  • Has zero CPU cost
  • Runs only at compile time
  • Applies only to macros

4. FASTSRT site option affects:

  • How the installation sort product handles I/O during sorts
  • Compile listing pagination only
  • SCREEN color attributes
  • JCL JOB card syntax

5. SEARCH on an indexed TABLE file when ARG equals the key:

  • Can become a keyed READ for faster access
  • Always scans the entire table
  • Disables FILE-STATUS
  • Requires SCREEN activity

Frequently Asked Questions

What uses the most CPU in typical Easytrieve batch?

Sort and report formatting dominate many jobs: SORT/SEQUENCE compare-merge, LINE and mask evaluation per row, and control-break processing. I/O waits show as elapsed time but sort and format work show as CPU.

Will converting one field to binary fix my job?

Only if arithmetic on that field is a proven hotspot. Profile with representative data first. Converting all fields blindly adds conversion overhead at I/O boundaries without benefit.

Do macros reduce CPU?

Macros reduce maintenance and duplicate compile size; they do not magically shrink runtime CPU. They help organizations avoid copy-paste drift that leads to accidental extra SORT or DISPLAY statements.

How does SELECT reduce CPU?

Fewer input rows mean fewer sort comparisons, LINE formats, and break evaluations—CPU drops roughly with row reduction when the expensive steps are per-row.

Should I use compile-and-go to save CPU?

No. Compile-and-go adds compile CPU every run. Link-edit load modules remove repeated compile cost in production.

Published
Read time14 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Code Efficient Programs, Using Best Practices CPU guidance, FASTSRTSources: Broadcom Easytrieve 11.6 Code Efficient Programs and Using Best PracticesApplies to: Easytrieve CPU tuning for batch report and extract programs