Nvhost_job_alloc cpu usage

Hello.
We’re using hardware color space converter(CSC) and H264 Encoder(ENC), but they uses too many CPU-time.
Our system contains 4 or 6 cameras and each camera uses CSC and ENC at 30 fps. We’re using native API from the tegra_multimedia_api package.
In result, each camera uses about 40% CPU. We think it is too high for hardware blocks.

We found what is using CPU: it is functions “nvhost_channelctl” and “nvhost_job_alloc”.
As I found - “nvhost_job_alloc” calls one time for each call for CSC and more than 2 times for each ENC frame.
We have very high CPU usage and now nvhost_job_alloc’s calls are first candidate for optimization.
How to reduce CPU usage for CSC and ENC?

4 Likes

Hi,
For profiling CPU loading, please run sudo jetson_clocks to fix CPUs at max clocks, and sudo tegrastats to print out the status.

To eliminate other factors and get clean CPU loading of camera, you can run

$ gst-launch-1.0 nvarguscamerasrc ! fakesink

With one camera ov5693:

nvidia@jetson:~$ tegrastats
RAM 1028/31927MB (lfb 7585x4MB) CPU [15%@2265,5%@2265,0%@2265,0%@2265,7%@2265,2%@2265,6%@2265,8%@2265] EMC_FREQ 0% GR3D_FREQ 0% AO@46C GPU@46C Tdiode@49C PMIC@100C AUX@44C CPU@46C thermal@45.2C Tboard@45C GPU 930/930 CPU 1549/1549 SOC 4803/4803 CV 0/0 VDDRQ 465/465 SYS5V 2411/2411
RAM 1028/31927MB (lfb 7585x4MB) CPU [13%@2265,1%@2265,1%@2265,0%@2265,4%@2265,2%@2265,10%@2265,9%@2265] EMC_FREQ 0% GR3D_FREQ 0% AO@46C GPU@46C Tdiode@49C PMIC@100C AUX@44C CPU@46C thermal@45.2C Tboard@45C GPU 930/930 CPU 1395/1472 SOC 4803/4803 CV 0/0 VDDRQ 465/465 SYS5V 2371/2391
RAM 1028/31927MB (lfb 7585x4MB) CPU [14%@2265,2%@2265,0%@2265,0%@2265,5%@2265,1%@2265,7%@2265,9%@2265] EMC_FREQ 0% GR3D_FREQ 0% AO@46C GPU@45.5C Tdiode@49C PMIC@100C AUX@44C CPU@46C thermal@45.2C Tboard@45C GPU 930/930 CPU 1549/1497 SOC 4803/4803 CV 0/0 VDDRQ 465/465 SYS5V 2411/2397
RAM 1028/31927MB (lfb 7585x4MB) CPU [13%@2265,1%@2265,0%@2265,0%@2265,4%@2265,3%@2265,7%@2265,8%@2265] EMC_FREQ 0% GR3D_FREQ 0% AO@46C GPU@46C Tdiode@49C PMIC@100C AUX@44C CPU@46C thermal@45.2C Tboard@45C GPU 930/930 CPU 1395/1472 SOC 4803/4803 CV 0/0 VDDRQ 465/465 SYS5V 2411/2401
RAM 1028/31927MB (lfb 7585x4MB) CPU [13%@2265,0%@2265,0%@2265,0%@2265,4%@2265,2%@2265,7%@2265,7%@2265] EMC_FREQ 0% GR3D_FREQ 0% AO@46C GPU@46C Tdiode@49C PMIC@100C AUX@44C CPU@46C thermal@45.2C Tboard@45C GPU 930/930 CPU 1550/1487 SOC 4803/4803 CV 0/0 VDDRQ 465/465 SYS5V 2371/2395
RAM 1028/31927MB (lfb 7585x4MB) CPU [15%@2265,2%@2265,1%@2265,3%@2265,6%@2265,6%@2265,6%@2265,5%@2265] EMC_FREQ 0% GR3D_FREQ 0% AO@46C GPU@46C Tdiode@49C PMIC@100C AUX@44.5C CPU@46C thermal@45.4C Tboard@45C GPU 930/930 CPU 1549/1497 SOC 4803/4803 CV 0/0 VDDRQ 465/465 SYS5V 2411/2397
RAM 1028/31927MB (lfb 7585x4MB) CPU [12%@2265,1%@2265,0%@2265,1%@2265,4%@2265,1%@2265,8%@2265,6%@2265] EMC_FREQ 0% GR3D_FREQ 0% AO@46C GPU@45.5C Tdiode@49C PMIC@100C AUX@44.5C CPU@46C thermal@45.4C Tboard@45C GPU 930/930 CPU 1395/1483 SOC 4803/4803 CV 0/0 VDDRQ 465/465 SYS5V 2411/2399
RAM 1028/31927MB (lfb 7585x4MB) CPU [14%@2265,3%@2265,0%@2265,0%@2265,5%@2265,1%@2265,4%@2265,8%@2265] EMC_FREQ 0% GR3D_FREQ 0% AO@46C GPU@46C Tdiode@49C PMIC@100C AUX@44C CPU@46C thermal@45.4C Tboard@45C GPU 930/930 CPU 1549/1491 SOC 4803/4803 CV 0/0 VDDRQ 465/465 SYS5V 2371/2396
RAM 1028/31927MB (lfb 7585x4MB) CPU [13%@2265,3%@2265,0%@2265,0%@2265,7%@2265,0%@2265,4%@2265,9%@2265] EMC_FREQ 0% GR3D_FREQ 0% AO@46C GPU@46C Tdiode@49.25C PMIC@100C AUX@44.5C CPU@46.5C thermal@45.2C Tboard@45C GPU 930/930 CPU 1395/1480 SOC 4803/4803 CV 0/0 VDDRQ 465/465 SYS5V 2411/2397

in htop I see: about 20% CPU usage from the /usr/sbin/nvargus-daemon and about 5% from gst-launch-1.0 nvarguscamerasrc ! fakesink

But our camera isn’t bayer, it have yuyv 1280x1080 format

Hi,
Please execute with sudo to get loading@freq of EMC and GPU. And if you use YUV sensors, you can try the sample:

/usr/src/jetson_multimedia_api/samples/12_camera_v4l2_cuda/