Skip to content

Commit 9e11d07

Browse files
committed
Add more quicklist info to DEBUG OBJECT
Adds: ql_compressed (boolean, 1 if compression enabled for list, 0 otherwise) Adds: ql_uncompressed_size (actual uncompressed size of all quicklistNodes) Adds: ql_ziplist_max (quicklist max ziplist fill factor) Compression ratio of the list is then ql_uncompressed_size / serializedlength We report ql_uncompressed_size for all quicklists because serializedlength is a _compressed_ representation anyway. Sample output from a large list: 127.0.0.1:6379> llen abc (integer) 38370061 127.0.0.1:6379> debug object abc Value at:0x7ff97b51d140 refcount:1 encoding:quicklist serializedlength:19878335 lru:9718164 lru_seconds_idle:5 ql_nodes:21945 ql_avg_node:1748.46 ql_ziplist_max:-2 ql_compressed:0 ql_uncompressed_size:1643187761 (1.36s) The 1.36s result time is because rdbSavedObjectLen() is serializing the object, not because of any new stats reporting. If we run DEBUG OBJECT on a compressed list, DEBUG OBJECT takes almost *zero* time because rdbSavedObjectLen() reuses already-compressed ziplists: 127.0.0.1:6379> debug object abc Value at:0x7fe5c5800040 refcount:1 encoding:quicklist serializedlength:19878335 lru:9718109 lru_seconds_idle:5 ql_nodes:21945 ql_avg_node:1748.46 ql_ziplist_max:-2 ql_compressed:1 ql_uncompressed_size:1643187761
1 parent 02bb515 commit 9e11d07

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/debug.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,32 @@ void debugCommand(redisClient *c) {
306306
char *nextra = extra;
307307
int remaining = sizeof(extra);
308308
quicklist *ql = val->ptr;
309-
double avg = (double)ql->count/ql->len;
309+
/* Add number of quicklist nodes */
310310
int used = snprintf(nextra, remaining, " ql_nodes:%u", ql->len);
311311
nextra += used;
312312
remaining -= used;
313-
snprintf(nextra, remaining, " ql_avg_node:%.2f", avg);
313+
/* Add average quicklist fill factor */
314+
double avg = (double)ql->count/ql->len;
315+
used = snprintf(nextra, remaining, " ql_avg_node:%.2f", avg);
316+
nextra += used;
317+
remaining -= used;
318+
/* Add quicklist fill level / max ziplist size */
319+
used = snprintf(nextra, remaining, " ql_ziplist_max:%d", ql->fill);
320+
nextra += used;
321+
remaining -= used;
322+
/* Add isCompressed? */
323+
int compressed = ql->compress != 0;
324+
used = snprintf(nextra, remaining, " ql_compressed:%d", compressed);
325+
nextra += used;
326+
remaining -= used;
327+
/* Add total uncompressed size */
328+
unsigned long sz = 0;
329+
for (quicklistNode *node = ql->head; node; node = node->next) {
330+
sz += node->sz;
331+
}
332+
used = snprintf(nextra, remaining, " ql_uncompressed_size:%lu", sz);
333+
nextra += used;
334+
remaining -= used;
314335
}
315336

316337
addReplyStatusFormat(c,

0 commit comments

Comments
 (0)