mirror of
https://github.com/fluencelabs/redis
synced 2025-04-08 10:28:04 +00:00
used_memory_human added to INFO output. Human readable amount of memory used.
This commit is contained in:
parent
ace065423e
commit
ec6c7a1d78
4
TODO
4
TODO
@ -13,11 +13,9 @@ VERSION 1.4 TODO (Hash type)
|
|||||||
|
|
||||||
Virtual Memory sub-TODO:
|
Virtual Memory sub-TODO:
|
||||||
* Check if the page selection algorithm is working well.
|
* Check if the page selection algorithm is working well.
|
||||||
* Fix support for large files
|
|
||||||
* Divide swappability of objects by refcount
|
* Divide swappability of objects by refcount
|
||||||
* While loading DB from snapshot or AOF, swap objects as needed if maxmemory
|
|
||||||
is reached, calling swapOneObject().
|
|
||||||
* vm-swap-file <filename>. The swap file should go where the user wants, and if it's already there and of the right size we can avoid to create it again.
|
* vm-swap-file <filename>. The swap file should go where the user wants, and if it's already there and of the right size we can avoid to create it again.
|
||||||
|
* it should be possible to give the vm-max-memory option in megabyte, gigabyte, ..., just using 2GB, 100MB, and so forth.
|
||||||
|
|
||||||
VERSION 1.6 TODO (Virtual memory)
|
VERSION 1.6 TODO (Virtual memory)
|
||||||
=================================
|
=================================
|
||||||
|
25
redis.c
25
redis.c
@ -5407,6 +5407,27 @@ static void sortCommand(redisClient *c) {
|
|||||||
zfree(vector);
|
zfree(vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Convert an amount of bytes into a human readable string in the form
|
||||||
|
* of 100B, 2G, 100M, 4K, and so forth. */
|
||||||
|
static void bytesToHuman(char *s, unsigned long long n) {
|
||||||
|
double d;
|
||||||
|
|
||||||
|
if (n < 1024) {
|
||||||
|
/* Bytes */
|
||||||
|
sprintf(s,"%lluB",n);
|
||||||
|
return;
|
||||||
|
} else if (n < (1024*1024)) {
|
||||||
|
d = (double)n/(1024);
|
||||||
|
sprintf(s,"%.2fK",d);
|
||||||
|
} else if (n < (1024LL*1024*1024)) {
|
||||||
|
d = (double)n/(1024*1024);
|
||||||
|
sprintf(s,"%.2fM",d);
|
||||||
|
} else if (n < (1024LL*1024*1024*1024)) {
|
||||||
|
d = (double)n/(1024LL*1024*1024);
|
||||||
|
sprintf(s,"%.2fM",d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Create the string returned by the INFO command. This is decoupled
|
/* Create the string returned by the INFO command. This is decoupled
|
||||||
* by the INFO command itself as we need to report the same information
|
* by the INFO command itself as we need to report the same information
|
||||||
* on memory corruption problems. */
|
* on memory corruption problems. */
|
||||||
@ -5414,7 +5435,9 @@ static sds genRedisInfoString(void) {
|
|||||||
sds info;
|
sds info;
|
||||||
time_t uptime = time(NULL)-server.stat_starttime;
|
time_t uptime = time(NULL)-server.stat_starttime;
|
||||||
int j;
|
int j;
|
||||||
|
char hmem[64];
|
||||||
|
|
||||||
|
bytesToHuman(hmem,server.usedmemory);
|
||||||
info = sdscatprintf(sdsempty(),
|
info = sdscatprintf(sdsempty(),
|
||||||
"redis_version:%s\r\n"
|
"redis_version:%s\r\n"
|
||||||
"arch_bits:%s\r\n"
|
"arch_bits:%s\r\n"
|
||||||
@ -5426,6 +5449,7 @@ static sds genRedisInfoString(void) {
|
|||||||
"connected_slaves:%d\r\n"
|
"connected_slaves:%d\r\n"
|
||||||
"blocked_clients:%d\r\n"
|
"blocked_clients:%d\r\n"
|
||||||
"used_memory:%zu\r\n"
|
"used_memory:%zu\r\n"
|
||||||
|
"used_memory_human:%s\r\n"
|
||||||
"changes_since_last_save:%lld\r\n"
|
"changes_since_last_save:%lld\r\n"
|
||||||
"bgsave_in_progress:%d\r\n"
|
"bgsave_in_progress:%d\r\n"
|
||||||
"last_save_time:%ld\r\n"
|
"last_save_time:%ld\r\n"
|
||||||
@ -5444,6 +5468,7 @@ static sds genRedisInfoString(void) {
|
|||||||
listLength(server.slaves),
|
listLength(server.slaves),
|
||||||
server.blockedclients,
|
server.blockedclients,
|
||||||
server.usedmemory,
|
server.usedmemory,
|
||||||
|
hmem,
|
||||||
server.dirty,
|
server.dirty,
|
||||||
server.bgsavechildpid != -1,
|
server.bgsavechildpid != -1,
|
||||||
server.lastsave,
|
server.lastsave,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user