How myAPM Empowers Mobile App Performance Monitoring and Optimization
This article explains how Tencent's myAPM platform provides method‑level injection and monitoring for mobile apps, enabling automatic APK size analysis, lag detection, startup performance tracking, and core‑link analysis to help developers identify and eliminate unused code and performance bottlenecks.
Introduction
User experience has become a key product value, and performance perception is critical. Mobile apps face diverse devices, OS versions, and fragmented app versions, making it hard to resolve performance issues during development or testing.
What is myAPM?
myAPM is an Application Performance Management (APM) solution focused on mobile performance. It monitors and locates performance problems (lags) and supports daily app performance operation analysis to improve user experience.
Monitoring Method
myAPM uses BCI injection to achieve business‑method‑level monitoring.
The injection technology is similar to ASM but offers better efficiency, error‑checking, and lower learning cost.
Injection Stage
myAPM injects monitoring capabilities during the compilation stage, achieving zero‑coupling with development.
myAPM Features
Automatic method‑level injection monitoring.
Plugin‑based design allowing flexible feature composition.
What can myAPM do?
myAPM is applied in four main areas:
1. APK size analysis 2. App lag monitoring 3. App startup performance analysis 4. Core‑link performance analysis
1. APK Size Analysis
As features grow, APK size inflates, bringing “garbage” code that hampers releases and user experience. Manual global analysis is inefficient.
myAPM injects a unique ID into classes or methods, filters out called code in internal testing, then re‑injects IDs for uncalled code and collects real‑user behavior in a gray‑release environment. Long‑term data reveals truly unused code for developers to clean.
Principle
Inject a unique ID into each class/method.
Use extensive automated tests in internal environment to filter called code.
Re‑inject IDs for uncalled code, deploy to gray‑release, collect real‑user data.
Identify unused code from large‑scale data and guide developers to clean it.
Application Scenarios
Locate completely unused classes (coarse grain, easy cleanup).
Find isolated methods with no callers or callees (fine grain, thorough cleanup).
Identify uncalled method chains.
Characteristics
Combines offline simulated testing with online user behavior big‑data analysis.
Low performance overhead.
Automatic injection.
Open‑Source Tools & APK Analysis
Open‑source tools can list unused code, but they cannot determine call chains without online user data; myAPM fills this gap.
Method Injection Example
Reporting a unique ID (e.g., 14236) avoids leaking sensitive information and reduces reporting volume.
Qzone Android Case
In internal testing, 42% of classes were unused; in gray‑release, all classes were called, but 40% had fewer than 10 calls, suggesting they could be delayed‑loaded to improve startup.
Current Qzone app has no redundant unused classes.
Future work will deepen analysis to class‑method level.
2. App Lag Analysis
Main‑thread lag is the most intolerable issue for users. myAPM monitors method‑level lag by injecting timestamps before and after target method execution.
Working Principle
Inject monitoring code at compile time; after release, myAPM records execution time of each monitored method. When a lag is detected, the full call chain and device metrics are reported.
Full Process
Inject IDs based on caller‑callee pairs during compilation.
After release, monitor method execution time and report lag chains with environment info.
Backend reconstructs call chain from IDs for developers to analyze.
Examples
Common lag sources include main‑thread DB queries, dex loading, XML parsing, and image processing. myAPM provides average latency views and detailed instance lists.
Other cases: dex file loading, local XML loading, and heavy image processing (e.g., Process() took 1.3 s, setFacadeImage() took 1 s).
Advantages
Method‑level granularity.
Lightweight business‑stack reporting avoids heavy native stack printing (0.1‑0.3 ms vs. 1‑3 ms).
Small data payload using chain IDs instead of full stacks.
Zero impact on business code; injection is transparent.
Limitations & Solutions
Injection slightly increases APK size (e.g., +0.5 MB, 2.79% for Qzone). Solutions: selective injection or combine with APK size analysis for slimming.
New Features of myAPM
Beyond lag detection, myAPM now supports broader performance monitoring.
1. Startup Performance Monitoring
Customizable monitoring scope to focus on startup methods.
Track startup performance across versions and compare products.
2. Core‑Link Analysis
Identify core code paths, monitor their performance, and detect degradation across releases.
3. Delayed Loading
Detect rarely used, non‑core code and defer its loading to improve startup speed.
Conclusion
myAPM is Tencent’s mobile‑focused APM solution that not only locates performance problems but also supports daily performance operation analysis, helping teams keep their mobile apps lean and responsive.
Efficient Ops
This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.