Rate This Document
Findability
Accuracy
Completeness
Readability

Tuning TCMalloc

TCMalloc is a memory allocator developed by Google. It can tackle with memory fragmentation and supports parallelism based on multi-core processors. Its memory allocation speed is several times faster than malloc implemented in glibc 2.3.

  1. Enables TCMalloc.

    When executing the SPDK startup command, load the TCMalloc function library by using LD_PRELOAD. For example:

    LD_PRELOAD=/usr/lib64/libtcmalloc.so.4 build/bin/vhost -S /var/tmp -m 0x2
  2. Enable huge pages for TCMalloc.
    1. Configure TCMalloc environment variables.
      TCMALLOC_MEMFS_MALLOC_PATH=/dev/hugepages/tcmalloc 

      Change /dev/hugepages to the actual mount point of the huge page memory.

    2. Enable huge pages for TCMalloc.
      TCMALLOC_MEMFS_MALLOC_PATH=/dev/hugepages/tcmalloc LD_PRELOAD=/usr/lib64/libtcmalloc.so.4 build/bin/vhost -S /var/tmp -m 0x2