We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
Best PracticesPower Consumption Analysis of Applications' Power ConsumptionHigh CPU Load Analysis

High CPU Load Analysis

Obtaining Logs

To analyze the high CPU load issue, you need to start an Energy analysis task in the Profiler and reproduce the issue.

The IDE integrates a diagnostic feature for detecting abnormal high CPU load scenarios. The procedure is as follows:

  1. Click the Profiler, select the application process to be analyzed, create an Energy session, operate the application according to the reproduction path, and capture information for about 15 seconds.
  2. Observe the Energy Anomaly lane. If an anomaly is marked in red, a high CPU load anomaly has been identified.

    NOTE

    The CPU load is the average load within 3 seconds. If a thread runs at the maximum frequency of the big core for 3 seconds, the load reaches 100%. If a thread runs on different cores at different frequencies for different durations, the load is proportionally calculated according to the chip computing capability and running time.

  3. Click the arrow in More to view the functions that take a long time to execute. Then, analyze the causes of the long execution time.

Analysis

High CPU load may occur in the following scenarios:

  1. High GC thread load. In this case, analyze memory usage through the Allocation and Snapshot templates.
  2. High UI thread load. In this case, check whether redundant drawing exists and whether components are not reused based on the Trace lane. The analysis focuses on the frame rate, frame length, and display failures within the main application process, render_service, RSUniRenderThre, and RSHardwareThread pipelines.
  3. High load of other threads. In this case, analyze the function stack base on the Callstack lane and identify if there are any abnormalities in the application's service logic, if long-duration tasks are being frequently executed, or if an infinite loop has occurred due to irregularities in the service logic.

For above cases, conduct a thorough analysis to pinpoint the issue. After confirming the root cause, fix it. Then, monitor whether power consumption and thermal performance meet the performance requirements. If not, repeat the aforementioned analysis and troubleshooting steps.

Analysis Procedure

Case 1: High Load of an Application Thread

When an application is used to watch videos while simultaneously viewing comments or recommendations, the mobile phone becomes severely overheated. The device temperature gradually returns to normal after the application is closed.

  1. Enable the Energy template analysis in Profiler and reproduce the issue.
  2. Observe the CPU Core lane to locate the thread with a longer running duration. For details, see CPU Activity Analysis.

    Select the CPU Core lane. You can see the duration of application processes is relatively longer in the details panel.

    By checking the CPU frequencies in the Frequency lane, it can be seen that the frequencies for CPU cores are high, and CPU scheduling is frequent.

    The Frequency sub-lane indicates the CPU frequency. Hovering your mouse over the Frequency sub-lane displays the CPU's running frequency.

    When the frequencies of all CPU cores are high, select the CPU Core lane to view the CPU load source. In the details panel, you can see the CPU load primarily originates from the sub-threads (thread ID: 55523) on the application side.

  3. Check the issue based on the threads with high CPU load. In this case, the CPU load is mainly caused by the sub-thread (thread ID: 55523) on the application side. You should use the Analyzing Touch Completion Latency to analyze the tasks executed by the thread and investigate if there are any abnormalities in the service logic based on the function stack. This issue typically arises when the thread repeatedly executes time-consuming tasks or infinite loop logic.

Case 2: High GC Thread Load

During use of an application, the screen becomes severely hot, with the case temperature reaching as high as 40°C; after the application is closed, the temperature automatically returns to normal.

  1. Enable the Energy template analysis in Profiler and reproduce the issue.
  2. Observe the CPU Core lane to locate the thread with a longer running duration. For details, see CPU Activity Analysis.

    Select the CPU Core lane. You can see the duration of application processes is relatively longer in the details panel. The application process name varies depending on the application. Generally, it is the same as the application bundle name.

    By checking the CPU frequencies in the Frequency lane, it can be seen that the frequencies for some CPU cores stay in the highest state during runtime. As shown in the following figure, CPU 10 and CPU 11 have their corresponding Frequency sub-lanes basically filled.

    When the frequencies of some cores are high, select the Slice sub-lane corresponding to the core with a higher CPU frequency to view the CPU load source. That is, for the Slice sub-lanes corresponding to CPU 10 and CPU 11, you can see that the CPU load mainly comes from the OS_GC_Thread thread of the application process in the details panel.

  3. Check the issue based on the threads with high CPU load. In this case, the CPU load is mainly caused by the OS_GC_Thread thread of the application process. When the GC thread load is high, you should analyze memory usage through the Allocation and Snapshot templates. For details, see Memory Analysis: Allocation and Memory Leak Analysis: Snapshot.

Case 3: High UI Main Thread Load

When live streaming is watched on an application, the power consumption exceeds 100 mA and phone temperature is continuously rising.

  1. Enable the Energy template analysis in Profiler and reproduce the issue.
  2. Observe the CPU Core lane to locate the thread with a longer running duration. For details, see CPU Activity Analysis.

    Select the CPU Core lane. You can see the duration of application processes is relatively longer in the details panel.

    By checking the CPU frequencies in the Frequency lane, it can be seen that the frequencies for some CPU cores (CPU 10 and CPU 11) are high, and each CPU core scheduling is frequent.

    Check the CPU load sources in the details panel under the CPU Core lane. In the details panel, you can see that the CPU load mainly comes from the main thread of the application UI (thread ID 43436, which matches the application process ID).

  3. Check the issue based on the threads with high CPU load. In this case, the CPU load mainly comes from the application UI's main thread. You should analyze whether redundant drawing exists and whether components are not reused based on the Trace lane of the UI main thread.

    First, find the Trace lane corresponding to the UI main thread, which can be found using the application bundle name or the thread ID obtained in the previous step. Second, choose the corresponding thread lane and then choose Thread States in the details panel to see that the proportion of threads in the Running state is very high.

    Third, in Slice List panel, check whether redundant drawing exists and whether components are not reused. You can see that the image with [id: -1] continuously performs the drawing task, with occurrences reaching over 40,000. Also, you can use ArkUI Inspector to check related issues. For details about how to use the ArkUI Inspector, see Layout Analysis.

Search in Best Practices
Enter a keyword.