Only the Chinese version of this page is provided currently. The English version will be provided soon.

How to Optimize High CPU Usage

Last updated: 2025-05-14 16:44:00

Detailed Description

How to Optimize High CPU Utilization.

Cause Analysis

Encryption algorithms generally cause this issue, which is more obvious on low-end chips. By default, encryption features are enabled for Cloud Storage Video and P2P video transmission. Currently, the encryption algorithms used for Cloud Storage Video and P2P video transmission are AES-CBC-128 and AES-CTR-128, respectively. Below are the benchmark test results of some encryption algorithms on different platforms:

It can be seen that the encryption performance of AES-CBC-256 on the Hi3516E series CPU is approximately 9600 KB/s (the performance of AES-CBC-128 is slightly higher than that of AES-CBC-256). Assuming the bitrate of Cloud Storage Video is 2 mbps, i.E., the data volume per second is approximately 256 KB, it can be calculated that the CPU utilization is approximately 3%. In actual use, affected by other businesses, the CPU utilization may exceed the estimate. The performance of AES-CTR-128 used in P2P video transmission is similar to that of AES-CBC-128. Suppose multiple users are simultaneously pulling and playing back streams on the device side, the CPU utilization will multiply, bringing significant pressure to the device side. The version of mbedtls used by the SDK is 2.16.9. Users can download the corresponding version and compile it to perform benchmark tests. Follow these steps: Set environment variables and compile.
export CC="XXXXX"
export CFLAGS="-std=c99"
make
./programs/test/benchmark
It is a performance testing program. Run this program on devices to view the benchmark test results and estimate the CPU utilization.

Solution

Users manually adapt to the hardware acceleration relevant APIs of mbedtls and replace the default mbedtls library in the SDK.
Disable the encryption feature (not recommended).