MemKeyDB requires Linux kernel 5.1 or higher. This version introduces KMEM DAX feature which is used to expose PMem device as a system-ram.
Information how to configure KMEM DAX are available on this blog post.
For automatic recognition of KMEM DAX NUMA node libdaxctl-devel (v66 or later) is necessary to be installed in your system.
MemKeyDB sources are available on github.
Libmemkind is used as a submodule so it need to initialized with:
% git submodule init % git submodule update
Building with Memkind as an allocator is done by:
% make MALLOC=memkind
The application has additional configuration parameters related to the handling of two types of memories.
The main one is the ability to define Memory Allocation Policy. It allow modifying mechanism how heap memory is allocated via zmalloc() function calls. It can target DRAM, Persistent Memory or both. In general, bigger allocations should be stored in Persistent Memory which provides a higher capacity, while smaller and more frequently used should be stored in DRAM.
Memory Allocation Policy is defined in redis.conf or via command line argument:
Parameters used when THRESHOLD policy is selected:
When Threshold policy is selected, application will check static-threshold parameter. Allocation of the size smaller than this threshold goes to DRAM. Allocation of the size equal or bigger than this threshold goes to Persistent Memory. Parameter can be modified when application is running using CONFIG SET.
Minimum allocation size measured in bytes which goes to Persistent Memory
Parameters used when RATIO policy is selected:
Application allocates part of data in DRAM and part in Persistent Memory based on value of internal dynamic threshold and dram-pmem-ratio. Application monitors DRAM and Persistent Memory utilization and modifies value of internal dynamic threshold by increasing or decreasing it to achieve expected dram-pmem-ratio.
The syntax of dram-pmem-ratio directive is the following:
dram-pmem-ratio <dram_value> <pmem_value>
Expected proportion of memory placement between DRAM and Persistent Memory. Real DRAM:PMEM ratio depends on workload and its variability. dram_value and pmem_value are values from range <1,INT_MAX>
Place 25% of all memory in DRAM and 75% in Persistent Memory
dram-pmem-ratio 1 3
Internal dynamic threshold have minimum possible limit defined by dynamic-threshold-min and maximum possible limit defined by dynamic-threshold-max. They should be adapted to the size of the objects handled by the database.
Initial value of dynamic threshold
Minimum value of dynamic threshold. The use of lower values for this parameter may be required when the database handles a large number of objects of small size and the target ratio is set to allocate mainly from PMem, e.g. when the majority of objects will be smaller than 64 bytes a dram-pmem-ratio is set to 1-8.
Maximum value of dynamic threshold
An additional parameter determines how often the application should monitor the current ratio and adjust the internal dynamic threshold.
DRAM/PMem ratio period measured in miliseconds
Common parameters :
The main hashtable may be one large allocation. In a situation where the base consists mainly of a large number of small keys and values, the allocation of the main hashtable affects significantly the PMem/DRAM ratio. On the other hand, as it is very often used for writing and reading, so it should be placed in DRAM. The following option allows you to choose where you want to allocate the hashtable to depending on your needs.
hashtable-on-dram yes/no – Keep hashtable structure on DRAM or on PMem
With the INFO MEMORY command it is possible to monitor the parameters used by application to maintain DRAM/PMem ratio. The following parameters have been added:
127.0.0.1:6379> info memory Memory … pmem_threshold:30 used_memory_dram:865144 used_memory_dram_human:844.87K used_memory_pmem:41216 used_memory_pmem_human:40.25K