Modifying Action Diagrams › Understanding Contexts › Function Contexts › Enhanced Array Support › Performance Considerations for Multiple-Instance Array Parameters
Performance Considerations for Multiple-Instance Array Parameters
When using multiple-instance array parameters (MIAPs), the following performance-related considerations apply:
- General performance considerations when using MIAPs
-
Even though a MIAP can have many instances, only a single pointer is passed by the operating system to the program, as is the case with a non-MIAP parameter. Therefore, in terms purely of the parameter being passed as a normal parameter or as a MIAP, there is no additional performance hit to using MIAPs.
- Performance considerations in programs that use MIAPs
-
Any Neither parameters that are passed to a function are explicitly initialized in the ZZINIT subroutine in that function. In the case of a MIAP parameter containing Neither subfields, this initialization occurs for every field, in every element in the MIAP.
- Performance considerations in programs that call other programs that use MIAPs
-
When one program calls another and passes a structure parameter (RCD or KEY), CA 2E generates code in the calling program to initialize the intermediate structures used to pass the parameters to the called program, to load those structures from the variables specified in the Action Diagram and to unload those structures into the return variables. This code is generated whether the parameter is defined as a MIAP or as a normal parameter.
- When the parameter is defined as a MIAPs
-
- If all the MIAP subfields are defined with the same usage (I, O, B or N), then the generator loads the entire array structure into and out of the intermediate structure using a single MOVE. By contrast, if the MIAP subfields have different usages, each field must be moved separately. Since the MOVE is repeated for every element of the MIAP, this can affect your performance. Additionally, the amount of code generated for a MIAP with varying-usage subfields can be significantly greater.
- As with fields passed as parameters in non-MIAPs, MIAP subfields with a usage of Neither are explicitly initialized prior to the call – this occurs even if all the subfields have a usage of Neither.
- As with fields passed as parameters in non-MIAPs, if any of the MIAP subfields are ISO-type fields (DT#, TM# or TS#), code is automatically generated to explicitly initialize them, whether or not they are passed with the same usage as all other subfields within the MIAP.
To ensure the best possible performance when using MIAPs, follow these guidelines as closely as you can
- All subfields within a MIAP should be defined with the same usage (I, O or B).
- MIAP subfields with a usage of Neither should be avoided.
- ISO-type MIAP subfields should be avoided.