Search code examples
redis

Redis used_memory_dataset_perc shows the wrong value


I get the following output from the Redis server when running redis-cli info memory:

used_memory:1065728
used_memory_human:1.02M used_memory_rss:10559488
used_memory_rss_human:10.07M
used_memory_peak:3430704
used_memory_peak_human:3.27M
used_memory_peak_perc:31.06%
used_memory_overhead:867432
used_memory_startup:809680
used_memory_dataset:198296
used_memory_dataset_perc:77.44%
allocator_allocated:1393904
allocator_active:1728512
allocator_resident:4517888
maxmemory:10485760
maxmemory_human:10.00M

So, used_memory_dataset_perc shows 77.44% but used_memory_dataset shows only 198296 (bytes). Since used_memory is 1065728 (bytes) it seems that used_memory_dataset_perc should not be 77.44% but rather somewhere around 19%... if used_memory_dataset_perc is the percentage of used_memory_dataset compared to used_memory.

Am I missing something here?


Solution

  • From the docs:

    used_memory_dataset_perc: The percentage of used_memory_dataset out of the net memory usage (used_memory minus used_memory_startup)

    In your case you have used_memory_startup of 809680. Taking that from the used_memory leaves ~256kb, which your used_memory_dataset of ~198kb is ~77% of.

    The used_memory_startup is the overhead of redis itself:

    Initial amount of memory consumed by Redis at startup in bytes