Performance instrumentation for Android apps
Oct 26, 2015Delyan Kratunov

Summary
This post details the development of a performance instrumentation system for Android apps that uses bytecode rewriting (via ASM) to inject logging code before Dalvik VM conversion. It addresses limitations of manual instrumentation and built-in profilers by automatically capturing detailed performance telemetry, including asynchronous execution across threads, to diagnose performance regressions and subtle bugs. Key technical challenges overcome include minimizing runtime overhead, handling asynchronous tracing, and managing a global stream of instrumentation events using a lock-free ring buffer.