www.espertech.comDocumentation

Chapter 22. Byte Code Generation

22.1. Introduction
22.2. Usage Notes
22.2.1. Criteria
22.2.2. Fallback
22.2.3. Logging
22.2.4. Debugging Generated Code

Esper generates byte code for EPL statements. Byte code generation is a technique that blends state-of-the-art from modern compilers and MPP databases.

Byte code generation can significantly speed up processing as it eliminates many virtual calls and especially megamorphic calls (a callsite with 3 or more possible implementations is megamorphic) as well as casts and branching. Byte code generation allows the runtime to optimize the generated code and allows the hardware to execute faster.

Tip

The engine implements the best architecture for performance engineering in data processing by performing byte code generation. Not all workloads can benefit from byte code generation to the same degree.

Byte code generation is enabled by default and can be disabled entirely. Please refer to Section 15.4.12, “Engine Settings Related to Byte Code Generation and Compilation” for configuration options.

For example, consider the expression a + b (field a plus field b). Upon creating a statement the engine performs these steps:

  1. Analyzes the expression and determines where fields a and b come from (for example event type or variable) and the field type (for example string or integer).

  2. Verifies that the addition arithmetic operation can indeed be applied to the two fields. It verifies that both fields are indeed numeric and can thus be added.

Without byte code generation, for example, in order to evaluate the expression a + b the VM makes 3 virtual calls: One to obtain the value of field a, one to obtain the value of field b and one to perform the + plus-operation.

With byte code generation the engine can reduce the number of virtual calls. In the best case the number of virtual calls to evaluate the a + b expression is one (for the invocation of the generated code itself).

All byte code generation takes place at time of EPL statement creation (and not at runtime).

You can log generated classes at INFO log level by setting the configuration flag for code logging as described in Section 15.4.16.5, “Byte Code Generation Logging”.

As an alternative you can configure your log provider configuration file by setting DEBUG level for class com.espertech.esper.codegen.compile.CodegenCompilerJanino (provider class may change between versions).