目录

CPU Activity Analysis

Function Description

You can use CPU analysis tasks to monitor the real-time CPU usage and thread status while your app/atomic service is running. In this way, you can learn about the CPU resource consumption over a specified period and examine critical system trace points (including those of the graphics system and application service framework) to perform more targeted optimization.

The CPU template supports the following lanes: Energy, CPU Core, and Process. This section describes the CPU Core and Process lanes. For details about the Energy lane, see Energy Consumption Diagnosis: Energy.

Before analysis, create a CPU analysis task and capture related data. For details, see In-depth Capture for Problem Locating. Alternatively, click Open File in the session area and import historical data.

Checking CPU Usage

  1. The CPU Core lane displays the CPU usage of the selected app or atomic service being profiled. Click options on the right side of the lane to open the drop-down list, and select the display content.

    • Slice and Frequency: Each sub-lane consists of the time slice and frequency. The time slice displays the processes and threads that occupy the CPU core.
    • Usage and Frequency: Each sub-lane consists of the CPU core usage and frequency.

    Drag to select the main lane to collect statistics on the CPU usage in the selected period. You can query the process statistics in multiple time slices, status statistics by thread, thread status statistics, and data statistics of all time slices.

  2. Expand the main lane. The sub-lane displays the scheduling information, frequency, and usage of each CPU core.

    When you hover over a time slice, the time slices of different processes are dimmed, helping you determine the association between time slices.

  3. Specify a time slice and view the statistics.

    • Click a time slice to query the basic running information and scheduling delay in this time slice.

    • Drag to select multiple time slices to view process statistics in these time slices and data statistics in all time slices.

    • When View Integrated Scheduling Chain is enabled, you can click a node in the CPU time slice lane to view the complete scheduling chain of a CPU running thread.

Querying Process Details

You can click on the toolbar to set whether to use the lite mode. In lite mode, trace data collection is significantly reduced, focusing only on the current process, the launcher process, and the render_service process.

The process lane displays the usage of each CPU core by the process. Expand the process lane to display the thread list and thread running status of the process.
  • Click a time slice in the running status. The running details of the thread in the time slice are displayed, including the start time, duration, running status, frequency, thread priority, process to which the thread belongs, thread to which the thread belongs, previous thread's runtime status, next thread's runtime status, and the waking thread. You can navigate to the previous or next thread's runtime status and jump to the state where the thread was awakened.

  • Drag to select multiple time slices in the Thread lane to view statistics of threads in different running states within the selected period, including the total duration, maximum duration, minimum duration, average duration, number of threads in the current state, and statistics for medium-load and heavy-load entries.

    The medium-load and heavy-load data is aggregated every 100 ms. A running duration between 24 ms and 48 ms (inclusive) is recorded as medium load, while a running duration greater than 48 ms is recorded as high load.

  • Drag to select the main lane to view statistical information about the parallelism of the threads under this process within the selected time period. The parallelism data is aggregated every 100 ms. You can inspect the total number of threads running within that 100 ms interval, the total time each thread is in parallel, and the degree of parallelism. Click a row to view the corresponding thread ID and the time period during which the thread runs.

    The value range of Parallelism is [1, number of CPU cores]. A smaller value indicates a lower degree of parallelism.

Viewing Trace Details

If a trace task exists, you can view the overlay of the trace task triggered by the current thread in the corresponding thread lane. Select a trace.
  • Click a trace in the lane to view its details, including the name, process, thread, start time, duration, and depth.
    • If you have customized traces for a thread, you can also view the user trace information.
    • You can identify the trace type based on the thread name. The thread name corresponding to a system trace is in the format of thread name + thread number, and the thread name corresponding to a user trace is in the format of trace task name.

  • Drag to select multiple traces to view the trace statistics list, including the trace names, total duration of this type of trace, average duration of a single trace, and number of times that this type of trace is triggered within the period.