In modern Android application performance engineering, cold startup speed, smooth UI frame rendering, and battery efficiency are directly determined by how the Android Runtime (ART) compiles application Dalvik Executable (DEX) bytecode into machine code. Rather than relying exclusively on ahead-of-time (AOT) compilation or pure just-in-time (JIT) interpretation, modern Android versions utilize a sophisticated hybrid compilation model driven by dexopt (DEX Optimization) and on-device profile-guided optimization (PGO). When applications are installed or updated, their DEX bytecode is processed using specific compilation filters—such as speed-profile, speed, quicken, or verify. For Android developers optimizing launch times and benchmarking baseline profiles, inspecting the active compilation status across installed packages is critical. Using the Android Debug Bridge (ADB), engineers can audit runtime compilation states and profile usage via dumpsys package dexopt.
Understanding ART Compilation Filters and the dexopt Architecture
The Android Runtime operates an incremental compilation pipeline managed by the system daemon installd and the compiler utility dex2oat. Key compilation filters governed by dexopt include:
- verify: Skips compilation entirely. ART verifies DEX bytecodes and executes code purely through the JIT interpreter. This provides minimal installation time and disk footprint at the expense of slower runtime execution.
- speed-profile (Default for Modern Android): Compiles only the frequently executed classes and methods identified in a profile file (such as Google Play Cloud Profiles or developer-shipped Baseline Profiles). All other cold paths remain JIT-interpreted. This achieves the optimal compromise between fast app startup and minimal storage consumption.
- speed: Compiles the entire application bytecode ahead-of-time into native machine code. It delivers maximum execution speed but consumes significantly more storage space and compilation time.
- everything: Compiles all bytecode and attempts to resolve and inline all symbols. Used primarily for performance benchmarking.
The dumpsys package dexopt command queries the package manager to report which compilation filter is actively applied to primary and secondary DEX files for every installed package.
Connecting via ADB and Verifying Shell Access
Ensure that your target Android device has Developer Options and USB Debugging enabled. Connect the device via USB or wireless ADB, and confirm that the ADB daemon recognizes the device:
adb devices
Confirm that your device serial is displayed with the device state before issuing shell diagnostic commands.
Querying the Complete Dexopt Status Dump
To inspect the active compilation status across all packages installed on the system, run:
adb shell dumpsys package dexopt
The resulting diagnostic dump outlines package paths, active compilation filters, compilation reasons, and profile utilization:
Dexopt state:
[com.example.myapp]
path: /data/app/~~a1b2c3d==/com.example.myapp-e4f5a6b==/base.apk
arm64: [status=speed-profile] [reason=bg-dexopt] [primary-abi]
[location is /data/app/~~a1b2c3d==/com.example.myapp-e4f5a6b==/oat/arm64/base.odex]
used-by-other-apps: false
[com.android.chrome]
path: /data/app/~~c7d8e9f==/com.android.chrome-1a2b3c4==/base.apk
arm64: [status=speed-profile] [reason=install] [primary-abi]
Filtering Compilation States by Target Package
Because querying all system packages produces thousands of lines of output, isolate metrics for a single target package using grep:
adb shell dumpsys package dexopt | grep -A 6 "com.example.myapp"
Key diagnostic metrics reported in the package entry include:
- status: The active compilation filter applied to the APK (e.g.,
speed-profile,speed,verify, orrun-from-apk). - reason: The trigger that initiated the compilation pass (e.g.,
install,bg-dexoptfor background idle maintenance,first-boot, orcmdline). - location: The physical file system path to the generated Optimized DEX (
.odex) and Virtual Dynamic DEX (.vdex) files.
Testing App Startup Across Compilation Modes
To evaluate how compilation filters impact your application’s cold startup latency, you can force ART to recompile your package using the package manager command-line utility.
To compile the application using the full Ahead-of-Time speed filter:
adb shell cmd package compile -m speed -f com.example.myapp
Re-verify the updated status in dumpsys package dexopt:
adb shell dumpsys package dexopt | grep -A 3 "com.example.myapp"
To reset the package back to uncompiled interpreted mode to evaluate worst-case launch performance:
adb shell cmd package compile -m verify -f com.example.myapp
Measure cold startup time using am start with the -W (wait) flag:
adb shell am start -W -n com.example.myapp/.MainActivity
Comparing the reported TotalTime between verify and speed demonstrates the exact startup acceleration delivered by ART compilation.
Auditing Cloud and Baseline Profiles Usage
When compiling with speed-profile, ART relies on runtime profile data stored on the device. To force ART to process the application’s embedded baseline profiles and compile hot code paths immediately:
adb shell cmd package compile -m speed-profile -f com.example.myapp
If the application reports status=speed-profile and launch latency matches fully compiled speeds, your Baseline Profiles are successfully resolving critical startup classes.
Triggering Background Dexopt Maintenance
Under normal device operation, Android executes background dexopt routines while the device is idle and connected to a charger (overnight maintenance). You can simulate this idle maintenance pass on demand across all packages:
adb shell cmd package bg-dexopt-job
Review the logcat stream to monitor compilation progress as ART optimizes pending packages based on accumulated user usage profiles.