Guidelines for Optimizing Performance
The COBOL-IT Compiler Suite provides guidelines for optimizing your generated code. You can cause large modules to be split into separate C functions. The "C" Compiler can then more effectively optimize the resulting code.
-O compiler flags
- The
-Os
compiler flag causes large modules to be split, and optimized C code to be produced. - The
-Os -O
sequence of compiler flags causes the "C" Compiler to optimize to reduce object size when compiling the optimized C code. - The
-O -Os
sequence of compiler flags causes the "C" Compiler to optimize to maximize execution speed, when compiling the optimized C code. Note that objects optimized for performance may be larger in size. - The
-O
compiler flag causes optimized C code to be produced, and causes the "C" Compiler to optimize to maximize execution speed. However, with very large modules, some "C" Compilers may fail. The-Os
compiler flag can be used to break the large modules down, and avoid this problem.
Optimizations enabled with the -O compiler flag
Compiler Flag | Default | What it does | Comments |
---|---|---|---|
bin |
No | Enables binary operation optimization. | bin-opt:yes is set by default with use of the –O compiler flag. If you wish to disable bin-opt when using –O ,use the –fno-bin-opt compiler flag. |
decimal-optimize:[yes/no] |
No | Enables optimization of the conversion of decimal-encoded numeric values to binary in COMPUTE statements. |
decimal-optimize:yes is set by default with use of the –O compiler flag.If you wish to disable decimal-optimize when using –O , use the –fno-decimal-optimize compiler flag. |
index-optimize : [yes/no] |
No | Enables optimization of MOVE and IF statements containing references to variables using indexes. As an example, MOVE data- item(1,3) to current- item . Or IF data- item(1,3) < 100 perform inventory-trigger . |
index-optimize is set to yes by default with the use of the –O compiler flag. If you wish to disable index-optimize when using –O , use the –fno-index-optimize compiler flag. |
binary-truncate:no |
Yes | Enables optimization of mathematical operations where a numeric field is described with a decimal notation, and contains an integer value with no decimals, for example, PIC 99V99 VALUE 10. . Applies to the performance of the ADD , SUBTRACT , MULTIPLY and DIVIDE verbs. |
binary-truncate is set to yes by default. To achieve optimizations from binary-truncate when compiling with –O , set binary-truncate:no . |
notrunc:yes |
No | Same as binary-truncate:no |
notrunc is set to no by default. To achieve optimizations from notrunc when compiling with –O , set notrunc:yes . |
COB_OPTSIZE_FLAG
The environment variable COB_OPTSIZE_FLAG
can be used to name flags to be used in the C compilation phase.
Usage: To cause the -Os
flag to be used by the "C" Compiler
export COB_OPTSIZE_FLAG=-Os
The CALL statement
In applications with large numbers of CALL
statements, significant performance improvements can be gained by optimizing the performance of the CALL
statement. This is an overview of the compiler configuration file options, compiler flags and runtime environment variables that can improve the performance of the CALL
statement. In some cases, more details can be found at the documentation point of the flag.
CALL statement | Description |
---|---|
external-link:[function-name] |
Compiler Configuration Flag. Causes [function-name] to be declared as an external non-COBOL symbol. Causes CALL “function-name” to generate more efficient code. |
-fauto-load-symb |
Compiler Flag. Provides additional control, as regards static symbol definition, by causing the static.symb and user.symb files to be automatically loaded with the compiler configuration file. static.symb is provided with the compiler distribution, and should not be changed by the user. static.symb includes symbols declared by Pro*Cob and Tuxedo. |
-fcall-opt |
Compiler Flag. Stores the address of a symbol locally in module memory. Enables CALL statement optimization. Programs containing CANCEL statements should not be compiled with -fcall-opt . |
module-load-priority:yes COB_LOAD_PRIORITY |
Compiler Configuration Flag. Affects resolution of target of CALL statement. Normal sequence is (first) check linked library, and (then) check shared library. This reverses the sequence. module-load-priority:yes corresponds to the runtime environment variable COB_LOAD_PRIORITY=Y |
static-link:[function-name] |
Causes [function-name] to be linked statically. Improves the performance of the CALL statement. |
-x |
Compiler Flag. Generates native executable. |
COB_CALL_CASE=xul COB_LOAD_CASE=xul |
Runtime environment variables. COB_CALL_CASE and COB_LOAD_CASE runtime environment variables should be used together. Used together, they provide the user with control over how the target of a CALL statement is resolved. |
The PERFORM statement
In applications where PERFORM
statements execute a very high number of times, significant performance improvements can be seen by optimizing the PERFORM
.
Statement | Description |
---|---|
-freturn-opt |
Optimizes PERFORM return code. |
Resolving File Names
The process of resolving a file name can be time consuming where files as declared in a SELECT
phrase may have no extension, and full path-name. This performance penalty can be eliminated by using filename mapping.
Default | Description |
---|---|
External-mapping:yes |
Allows files declared as EXTERNAL to be resolved using environment variables. |
Filename-mapping:yes |
Allows fine names to be resolved at runtime using environment variables. |
Removing debug-oriented compiler flags
Debug-oriented compiler flags have performance penalties. When your code is well-tested, these compiler flags may no longer be needed, and can be removed to achieve better performance.
Compiler Flag | Description |
---|---|
-fcheckpoint |
Enables setting of checkpoints. Program state is saved at checkpoints, and can be reloaded. |
-debugdb=<debugDB> |
Stores metadata for debugging in SQLite3 database. |
-fdebug-exec |
Used for debugging of EXEC SQL statements. |
Exception-checking (EC-xxx) Compiler Configuration Flags.As an example: EC-SIZE:yes |
Enabled with –debug . |
-fmem-info |
Stores memory information, for analysis in the eventual cause of a crash. |
-fprofiling |
Adds counters to total statistics for reports on where your application is spending the most time. |
-fsource-location |
Generates source location code, enabling information to be dumped on source location when runtime aborts. Enabled by –g . |
-fstack-check |
Enables stack checking debug function. |
-ftrace -fsimpletrace -ftraceall |
The tracing compiler flags. Cause output to be written to an output file during the runtime execution. |
-ftrap-unhandled-exception |
Provides additional information when runtime aborts. |
-g |
Causes debugger metadata to be stored in the compiled object file or, if –DebugDB compiler flag is used, in an SQLite3 database. |
-G |
Produces debugging information, for purposes of debugging programs written in “C”. |
COB_ERROR_FILE |
Used when debugging are set to capture information for debugging purposes. |
COB_FILE_TRACE |
Causes data to be written to the COB_ERROR_FILE whenever there is a file I/O operation executed. |
COB_DUMP |
No longer required after your functionality tests have been completed. Creates an output file for the memory dump created when a runtime aborts. |
Optimizing performed at installation (Windows)
During the Windows install, the user is asked what version of Visual C compiler they are using. The compiler and runtime are compiled with the indicated version. This provides optimal performance.
Optimizing compiler flags set by default
The COBOL-IT Compiler Suite uses the following optimizations by default. These can be disabled by adding the no- prefix to the compiler flag. As an example, to disable the -fcmp-opt
compiler flag, use the -fno-cmp-opt
compiler flag.
Compiler Flag | Description |
---|---|
-fcmp-opt |
The –fcmp-opt compiler flag activates optimizations when comparing literals with variables. To disable, use the –fno-cmp-opt compiler flag. |
-ffast-figurative-move |
Fast MOVE of figurative constant. To disable, use the –fno-fast-figurtive-move compiler flag. |
-ffast-op |
Fast operation on numeric DISPLAY/COMP-3 . To disable, use the –fno-fast-op compiler flag. |
-foptimize-move |
Optimizes MOVE operations performed by INITIALIZE statement when target fields are USAGE DISPLAY NUMERIC or USAGE NATIONAL . To disable, use the –fno-optimize-move compiler flag. |