Properly set the queue depth to reduce hardware resource waste and improve performance.

Background

The API of the media data processing V2 version can be used to configure the VPC queue depth. The queue depth ranges from 10 to 350. When user services deliver tasks to a full VPC queue, VPC performs backpressure to block the tasks, which affects performance.

Principles

Increasing the VPC queue depth can reduce the impact of performance fluctuation between user service delivery and VPC internal task processing.

  • If the number of tasks delivered by a user within a short period of time is greater than the processing speed of the VPC channel, the extra tasks are cached in the queue and the user can continue to deliver tasks.
  • If a small number of tasks are delivered within a short period of time, the VPC can process the tasks cached in the queue, which does not cause idle resources and wastes hardware resources.

You can adjust the queue task depth based on the service task delivery speed and the VPC single-channel processing performance.

  • For a single channel that receives excessive tasks from multiple threads, you are advised to set the queue depth to a larger value.
  • A channel is created for a user service. Only one thread delivers a task to the channel. The task is delivered once and the result is obtained once. The task is executed in serial mode. retain the default value since there will be no awaited tasks.

Instructions for Use

When the hi_mpi_vpc_create_chn or hi_mpi_vpc_sys_create_chn API is called to create a VPC channel, the attr parameter in the hi_vpc_chn_attr structure is used to set the queue depth.

You can click vpc_sample to obtain the sample. For details about the sample code for setting the VPC queue depth, see the queue_len parameter in sample_vpc.cpp.