From 5127e3998058983351b6c0b94d1341f9d646c9cc Mon Sep 17 00:00:00 2001 From: Matt Stancliff Date: Wed, 10 Dec 2014 22:54:19 -0500 Subject: [PATCH] Add quicklist info to DEBUG OBJECT Added field 'ql_nodes' and 'ql_avg_per_node'. ql_nodes is the number of quicklist nodes in the quicklist. ql_avg_node is the average fill level in each quicklist node. (LLEN / QL_NODES) Sample output: 127.0.0.1:6379> DEBUG object b Value at:0x7fa42bf2fed0 refcount:1 encoding:quicklist serializedlength:18489 lru:8983768 lru_seconds_idle:3 ql_nodes:430 ql_avg_per_node:511.73 127.0.0.1:6379> llen b (integer) 220044 --- src/debug.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/debug.c b/src/debug.c index c464644c..e1761df3 100644 --- a/src/debug.c +++ b/src/debug.c @@ -301,13 +301,25 @@ void debugCommand(redisClient *c) { val = dictGetVal(de); strenc = strEncoding(val->encoding); + char extra[128] = {0}; + if (val->encoding == REDIS_ENCODING_QUICKLIST) { + char *nextra = extra; + int remaining = sizeof(extra); + quicklist *ql = val->ptr; + double avg = (double)ql->count/ql->len; + int used = snprintf(nextra, remaining, " ql_nodes:%lu", ql->len); + nextra += used; + remaining -= used; + snprintf(nextra, remaining, " ql_avg_node:%.2f", avg); + } + addReplyStatusFormat(c, "Value at:%p refcount:%d " "encoding:%s serializedlength:%lld " - "lru:%d lru_seconds_idle:%llu", + "lru:%d lru_seconds_idle:%llu%s", (void*)val, val->refcount, strenc, (long long) rdbSavedObjectLen(val), - val->lru, estimateObjectIdleTime(val)/1000); + val->lru, estimateObjectIdleTime(val)/1000, extra); } else if (!strcasecmp(c->argv[1]->ptr,"sdslen") && c->argc == 3) { dictEntry *de; robj *val;