The Datadog APM team optimized Java agent startup time by 30% by improving class-matching efficiency during the JVM's early execution phase. The approach involved encoding class-name prefix matches as JVM constants and developing a lightweight class-file parser to reduce the computational overhead of identifying classes for instrumentation.
Key points
Instrumentation overhead during JVM startup can be minimized by optimizing the class-matching phase before JIT compilation occurs.
Encoding multiple class-name prefix matches as a single JVM constant reduces the CPU cost of class identification.
Custom, minimal class-file parsers can significantly speed up structural matching compared to generic parsing libraries.
Dynamic programming can prevent redundant traversals when calculating class hierarchy matches.