From 6741bb981c53eb6b168e6ff96d915a0d51e0c7cd Mon Sep 17 00:00:00 2001 From: Matt Stancliff Date: Fri, 9 Jan 2015 17:00:43 -0500 Subject: [PATCH 1/2] Improve consistency of INFO MEMORY fields Adds used_memory_rss_human and used_memory_lua_human to match all the other fields reporting human-readable memory too. --- src/redis.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/redis.c b/src/redis.c index a4d9e562..0e02f85d 100644 --- a/src/redis.c +++ b/src/redis.c @@ -2700,9 +2700,12 @@ sds genRedisInfoString(char *section) { char hmem[64]; char peak_hmem[64]; char total_system_hmem[64]; + char used_memory_lua_hmem[64]; + char used_memory_rss_hmem[64]; size_t zmalloc_used = zmalloc_used_memory(); size_t total_system_mem = server.system_memory_size; char *evict_policy = maxmemoryToString(); + long long memory_lua = (long long)lua_gc(server.lua,LUA_GCCOUNT,0)*1024; /* Peak memory is updated from time to time by serverCron() so it * may happen that the instantaneous value is slightly bigger than @@ -2714,6 +2717,8 @@ sds genRedisInfoString(char *section) { bytesToHuman(hmem,zmalloc_used); bytesToHuman(peak_hmem,server.stat_peak_memory); bytesToHuman(total_system_hmem,total_system_mem); + bytesToHuman(used_memory_lua_hmem,memory_lua); + bytesToHuman(used_memory_rss_hmem,server.resident_set_size); if (sections++) info = sdscat(info,"\r\n"); info = sdscatprintf(info, @@ -2721,22 +2726,26 @@ sds genRedisInfoString(char *section) { "used_memory:%zu\r\n" "used_memory_human:%s\r\n" "used_memory_rss:%zu\r\n" + "used_memory_rss_human:%s\r\n" "used_memory_peak:%zu\r\n" "used_memory_peak_human:%s\r\n" "total_system_memory:%lu\r\n" "total_system_memory_human:%s\r\n" "used_memory_lua:%lld\r\n" + "used_memory_lua_human:%s\r\n" "mem_fragmentation_ratio:%.2f\r\n" "mem_allocator:%s\r\n" "maxmemory_policy:%s\r\n", zmalloc_used, hmem, server.resident_set_size, + used_memory_rss_hmem, server.stat_peak_memory, peak_hmem, (unsigned long)total_system_mem, total_system_hmem, - ((long long)lua_gc(server.lua,LUA_GCCOUNT,0))*1024LL, + memory_lua, + used_memory_lua_hmem, zmalloc_get_fragmentation_ratio(server.resident_set_size), ZMALLOC_LIB, evict_policy From 5a685f35a9e09cba3b08640912aed93acbc63351 Mon Sep 17 00:00:00 2001 From: Matt Stancliff Date: Fri, 9 Jan 2015 17:01:05 -0500 Subject: [PATCH 2/2] Add maxmemory limit to INFO MEMORY Since we have the eviction policy, we should have the memory limit too. --- src/redis.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/redis.c b/src/redis.c index 0e02f85d..56eb10aa 100644 --- a/src/redis.c +++ b/src/redis.c @@ -2702,6 +2702,7 @@ sds genRedisInfoString(char *section) { char total_system_hmem[64]; char used_memory_lua_hmem[64]; char used_memory_rss_hmem[64]; + char maxmemory_hmem[64]; size_t zmalloc_used = zmalloc_used_memory(); size_t total_system_mem = server.system_memory_size; char *evict_policy = maxmemoryToString(); @@ -2719,6 +2720,7 @@ sds genRedisInfoString(char *section) { bytesToHuman(total_system_hmem,total_system_mem); bytesToHuman(used_memory_lua_hmem,memory_lua); bytesToHuman(used_memory_rss_hmem,server.resident_set_size); + bytesToHuman(maxmemory_hmem,server.maxmemory); if (sections++) info = sdscat(info,"\r\n"); info = sdscatprintf(info, @@ -2733,9 +2735,11 @@ sds genRedisInfoString(char *section) { "total_system_memory_human:%s\r\n" "used_memory_lua:%lld\r\n" "used_memory_lua_human:%s\r\n" + "maxmemory:%lld\r\n" + "maxmemory_human:%s\r\n" + "maxmemory_policy:%s\r\n" "mem_fragmentation_ratio:%.2f\r\n" - "mem_allocator:%s\r\n" - "maxmemory_policy:%s\r\n", + "mem_allocator:%s\r\n", zmalloc_used, hmem, server.resident_set_size, @@ -2746,9 +2750,11 @@ sds genRedisInfoString(char *section) { total_system_hmem, memory_lua, used_memory_lua_hmem, + server.maxmemory, + maxmemory_hmem, + evict_policy, zmalloc_get_fragmentation_ratio(server.resident_set_size), - ZMALLOC_LIB, - evict_policy + ZMALLOC_LIB ); }