From 0053429a02a903d3947334bf4abf3c2160f81f2c Mon Sep 17 00:00:00 2001 From: NAM UK KIM Date: Sat, 24 Aug 2024 10:02:18 +0900 Subject: [PATCH] Update "Total" message and used_memory_human log information in serverCron() function (#594) At the VERBOSE/DEBUG log level, which is output once every 5 seconds, added to show the "Total" message of all clients and to show memory usage (used_memory) with used_memory_human. Also, it seems clearer to show "total" number of keys and the number of volatile in entire keys. --------- Signed-off-by: NAM UK KIM --- src/server.c | 8 ++++++-- src/server.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/server.c b/src/server.c index 2cd40d291..aaee46273 100644 --- a/src/server.c +++ b/src/server.c @@ -1331,9 +1331,13 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { /* Show information about connected clients */ if (!server.sentinel_mode) { run_with_period(5000) { - serverLog(LL_DEBUG, "%lu clients connected (%lu replicas), %zu bytes in use", + char hmem[64]; + size_t zmalloc_used = zmalloc_used_memory(); + bytesToHuman(hmem, sizeof(hmem), zmalloc_used); + + serverLog(LL_DEBUG, "Total: %lu clients connected (%lu replicas), %zu (%s) bytes in use", listLength(server.clients) - listLength(server.replicas), listLength(server.replicas), - zmalloc_used_memory()); + zmalloc_used, hmem); } } diff --git a/src/server.h b/src/server.h index c08dd5887..3530f4271 100644 --- a/src/server.h +++ b/src/server.h @@ -3303,6 +3303,7 @@ void adjustOpenFilesLimit(void); void incrementErrorCount(const char *fullerr, size_t namelen); void closeListeningSockets(int unlink_unix_socket); void updateCachedTime(int update_daylight_info); +void bytesToHuman(char *s, size_t size, unsigned long long n); void enterExecutionUnit(int update_cached_time, long long us); void exitExecutionUnit(void); void resetServerStats(void);