Description
Is your feature request related to a problem? Please describe.
Since OpenSearch KNN Plugin's native engine libraries are written in C++, they can suffer from both internal and external fragmentation by default memory locator(glibc). By adding support (preferably bundle jemalloc with OpenSearch similar to jdk ) to use jemalloc in supported platforms, knn query performance can be improved.
From multiple experiments it is clear that memory allocator can affect the query performance of database engines. jemalloc is a general purpose malloc implementation that emphasizes fragmentation avoidance and scalable concurrency support. It is also used as default memory allocator for applications like Redis, Facebook, Cassandra, Firefox, etc.
Describe the solution you'd like
In supported platforms, jemalloc can be bundled with OpenSearch and used as memory allocator at runtime by updating LD_PRELOAD. This doesn't require any code changes in opensearch knn plugin.
Describe alternatives you've considered
N/A
Additional context
OpenSearch knn team conducted experiments and verified that using jemalloc as memory allocator reduces memory fragmentation and improves query performance . Please see more details here