| Optimization and Debugging Problems |
|
|
|
Q. I've been trying to debug an ILE program that's been running for some time. Recently, I recreated the program with full optimization to improve performance. But now the debugger doesn't work. What am I doing wrong? A. When you optimize a module, the system streamlines the module to make the runtime performance as fast as possible (a nanosecond here, a nanosecond there...). As you've discovered, though, optimization can have adverse side effects when you are debugging the program or service program. Optimization may rearrange or eliminate some statements altogether. Consequently, field values presented by the debugger, as well as breakpoints and step locations, may be inaccurate. Optimization will also affect the accuracy of the DUMP operation and error handling routines (e.g., Monitor groups, *PSSR and INFSR subroutines). There are three levels of optimization, set by the OPTIMIZE keyword in H-specs (or in the CRTRPGMOD and CRTBNDRPG commands):
I'm not a big fan of optimization, because I don't believe the nearly imperceptible performance improvements justify the debugging problems. Also, the RPG IV Reference and the CL Reference have conflicting information about the effects of optimization. Optimization works best with call-intensive programs; it does not improve the performance of file I/O. In rare cases, optimization may actually make the program slower. I usually just leave the default OPTIMIZE(*NONE). If you do choose to optimize, some data items can "opt out" of the optimization process; use the NOOPT D-spec keyword to prevent optimization of those data items that you do not want to optimize. Using this option will cure the innacuracy problem (for those data items only). The DSPMOD, DSPPGM, and DSPSRVPGM commands will show you the current level of optimization for an object. You can change optimization levels with the CHGMOD, CHGPGM, or CHGSRVPGM commands; these commands support the levels already discussed, but also add other options:
|
Special pricing for the Ontario area. Book a 5-day onsite class for as little as USD $900/day. Get a price quote today. Ask for offer CA900.
5-day minimum, special terms apply.