Android GPU Inspector (AGI) is currently in open beta. Learn more.

AGI System Profiler

AGI's System Profiler allows you to take profiling traces of your application in the context of the entire Android system. The profiler can give you insights into your application's and system services' CPU, memory, and battery usage, as well as GPU counters and your application's GPU usage. The System Profiler is a powerful tool for analyzing your application's performance over many frames. The System Profiler is built on top of Android's Perfetto tracing system.

Capture a system profiler trace

To capture a System Profiler trace, connect a supported Android device and select the Capture a new trace option on AGI startup, or through the File > Capture Trace menu. This opens the trace capture dialog. Once you select your Android device, you can select System Profile from the Type list.

While selecting an application is optional for System Profiler traces, we recommend specifying your application, as you will only see your ATrace markers and the application's GPU activity in the resulting trace if you do. AGI will setup the environment to run your application in profiling mode and start it before capturing porifling data. To profile your application, it needs to have the debuggable flag set in its manifest, as described in the Getting started page.

System Profiler Trace Configuration

The System Profiler is highly configurable and allows you select exactly what profiling data you wish to collect. Collecting profiling data has some overhead and for longer traces it may be adventagous to only select data sources you care about in order to keep the overall trace size smaller. However, for shorter sub-minute traces, it is perfectly OK to select all data sources. To select what data to collect, press the "Configure" button in the "Trace Options" section of the dialog.

CPU Options

Enabling the CPU profiling data will cause CPU and process scheduling data to be collected via ftrace. This allows you to see what process and thread are executing on each of the CPU's core. You can optionally enable the following additional data via the checkboxes in the dialog:

  • Frequency and Idle States: This option enables collecting CPU core frequency and idle state change events, allowing you to inspect how the CPU is scaled up or down based on load.
  • Scheduling Chains / Latency: This option enables collecting additional thread state data that can give insights into thread scheduling delays and preemtpion.
  • Thread Slices: This option will enable collecting of ATrace markers in the process views.

GPU Options

Enabling the GPU profiling data will include the GPU's frequency an memory usage to be profiled and included in the trace. To get a better understanding of how busy the GPU is and where any bottlenecks may be, it is highly recommended to enable the GPU counter collection and select a set of relevant counters. The counters are hardware-specific; see our documentation for Arm Mali, Qualcomm Adreno, and Imagination PowerVR pages for details on what is available on your device. The frequency in μs at which to collect counter samples can also be configured. The minimum sampling period is also hardware-specific.

The GPU Activity option enables profling of your application's GPU usage. Similar to CPU scheduling data, this will show when the GPU was busy executing your apps command buffers and where it spent the time, such as vertex vs fragment work. The GPU activity slices allow you to peek inside the GPU blackbox and allow you to get a better understanding of how your application is using the GPU.

The Frame Lifecycle option enables tracing of SufaceFlinger events that can give you insights into how the frame buffers move through your application, the compositor, and window manager. These events make it very easy to see where your application may have missed a frame and can help you track down sources of latency in your rendering pipeline.

Vulkan Options

The Vulkan section allows you to trace and get a handle on the CPU overhead of the Vulkan API calls. Selecting this option will include recording of time spent inside each Vulkan API function and display it in your application's thread slices. You can select which category of Vuklan API functions to include.

Other Options

There are a few other data sources that can be enabled in the trace configuration:

  • Memory: This enables periodic collection of essential memory usage statistics, both globally and per process.
  • Battery: This enables periodic collection of battery statistics. This can give you a rough estimate on power usage of your application.
  • Force Tracing into a File on the Device: Trace data is typically streamed over USB while the trace is being captured. This has the least amount of overhead and allows for large/long traces. However, if you encounter problems or dropped profiling data due to USB latency, you can select this option to trace to a file on the device, which AGI then downloads after tracing concludes. This requires sufficient space on your device's internal storage to store the trace file.

System profiling is done via the Perfetto tracing framework. If you are familiar with Perfetto and its configuration, you can use the advanced configuration mode to manually edit the Perfetto config protobuf that AGI generates based on the selected option for more fine-grained control over what profiling data to collect.