Security Hardening for Retrieval

Proper Memory Allocation

You need to properly plan the memory usage and ensure that the memory usage does not exceed the system resource limit. The feature database of retrieval services is stored in the DDR of the Ascend AI Processor. The temporary service memory and system memory determine the total memory usage when the feature dimensions and quantities are imported into the database, queried, and calculated. If the input is large, memory allocation on the device will fail. The actual memory size of an Ascend AI Processor-powered device determines the maximum database capacity corresponding to a single index. The number of indexes needs to be set based on service requirements to prevent memory usage from exceeding the threshold.

OMP Settings

Before modifying OMP configurations, evaluate the resource restrictions such as the system memory and number of threads. Otherwise, the system may run abnormally. For example, you can set the number of concurrent requests by setting ${OMP_NUM_THREADS}. For details about how to set OMP, see the official documents.

Port Utilization

Most retrieval APIs use input parameters of the C language. Therefore, you need to ensure that the length of an input pointer is valid. Otherwise, the running may be abnormal.

Conversion From faiss::Index

The function of converting faiss::Index is provided. Ensure that faiss::Index output by copyTo is not modified. Otherwise, APIs such as copyFrom, index_ascend_to_cpu, index_int8_ascend_to_cpu, index_cpu_to_ascend, and index_int8_cpu_to_ascend may be abnormal.