167
Kind Configuration Management
You can also create a heap with a specific configuration using the function memkind_
create_pmem_with_config(). This function requires completing a memkind_config
structure with optional parameters such as size, path to file, and memory usage policy.
Memory Usage Policy
In jemalloc, a runtime option called dirty_decay_ms determines how fast it returns
unused memory back to the operating system. A shorter decay time purges unused
memory pages faster, but the purging costs CPU cycles. Trade-offs between memory and
CPU cycles needed for this operation should be carefully thought out before using this
parameter.
The memkind library supports two policies related to this feature:
1. MEMKIND_MEM_USAGE_POLICY_DEFAULT
2. MEMKIND_MEM_USAGE_POLICY_CONSERVATIVE
The minimum and maximum values for dirty_decay_ms using the MEMKIND_MEM_
USAGE_POLICY_DEFAULT are 0ms to 10,000ms for arenas assigned to a PMEM kind.
Setting MEMKIND_MEM_USAGE_POLICY_CONSERVATIVE sets shorter decay times to purge
unused memory faster, reducing memory usage. To define the memory usage policy, use
memkind_config_set_memory_usage_policy(), shown below:
void memkind_config_set_memory_usage_policy (struct memkind_config *cfg,
memkind_mem_usage_policy policy );
• MEMKIND_MEM_USAGE_POLICY_DEFAULT is the default memory usage
policy.
• MEMKIND_MEM_USAGE_POLICY_CONSERVATIVE allows changing the
dirty_decay_ms parameter.
Listing 10-9 shows how to use memkind_config_set_memory_usage_policy() with a
custom configuration.
Chapter 10 Volatile Use of persistent MeMory
Précédent

- 191/457

Suivant