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 <namuk2004@naver.com>
This commit is contained in:
NAM UK KIM 2024-08-24 10:02:18 +09:00 committed by GitHub
parent b48596a914
commit 0053429a02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -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);