Apama 10.11.3 | Developing Apama Applications | Developing Apama Applications in EPL | Testing and Tuning EPL monitors | Optimizing EPL programs
 
Optimizing EPL programs
Best practices for optimizing EPL programs include:
*Minimize cost of spawning— avoid repeated spawning of monitors that contain a large number of variables.
*Allocate events — but not unnecessarily. See Avoiding unnecessary allocations.
*Specify wildcard on non-essential event fields. See Wildcard fields that are not relevant.
*Use plug-ins when you cannot write efficient EPL to accomplish your purpose. See When to use plug-ins.
*Minimize the effect of garbage collection
EPL, like languages such as Java or C#, relies on garbage collection. Intermittently, the correlator analyses the objects that have been allocated, including events, dictionaries and sequences, and allows memory used by objects that are no longer referenced to be re-used. Thus, the actual memory usage of the correlator might be temporarily above the size of all live objects. While running EPL, the correlator might wait until a listener, onload() action or stream network activation completes before performing garbage collection. Therefore, any garbage generated within a single action, listener invocation or stream network activation might not be disposed of before the action/listener/activation has completed. It is thus advisable to limit individual actions/listeners/activations to performing small pieces of work. This also aids in reducing system latency.
The cost of garbage collection increases as the number of events a monitor instance creates and references increases. If latency is a concern, it is recommended to keep this number low, dividing the working set by spawning new monitor instances if possible and appropriate. Reducing the number of object creations, including string operations that result in a new string being created, also helps to reduce the cost of garbage collection. The exact cost of garbage collection could change in future releases as product improvements are made.