diff --git a/src/debug.c b/src/debug.c index ed8329de..cd0469c7 100644 --- a/src/debug.c +++ b/src/debug.c @@ -250,11 +250,13 @@ void computeDatasetDigest(unsigned char *final) { } } +#if defined(USE_JEMALLOC) void inputCatSds(void *result, const char *str) { /* result is actually a (sds *), so re-cast it here */ sds *info = (sds *)result; *info = sdscat(*info, str); } +#endif void debugCommand(client *c) { if (!strcasecmp(c->argv[1]->ptr,"segfault")) { @@ -397,6 +399,7 @@ void debugCommand(client *c) { snprintf(buf,sizeof(buf),"value:%lu",j); val = createStringObject(buf,strlen(buf)); dbAdd(c->db,key,val); + signalModifiedKey(c->db,key); decrRefCount(key); } addReply(c,shared.ok); @@ -474,8 +477,20 @@ void debugCommand(client *c) { sds info = sdsempty(); je_malloc_stats_print(inputCatSds, &info, NULL); addReplyBulkSds(c, info); + } else if (!strcasecmp(c->argv[2]->ptr, "purge")) { + char tmp[32]; + unsigned narenas = 0; + size_t sz = sizeof(unsigned); + if (!je_mallctl("arenas.narenas", &narenas, &sz, NULL, 0)) { + sprintf(tmp, "arena.%d.purge", narenas); + if (!je_mallctl(tmp, NULL, 0, NULL, 0)) { + addReply(c, shared.ok); + return; + } + } + addReplyError(c, "Error purging dirty pages"); } else { - addReplyErrorFormat(c, "Valid jemalloc debug fields: info"); + addReplyErrorFormat(c, "Valid jemalloc debug fields: info, purge"); } #else addReplyErrorFormat(c, "jemalloc support not available"); diff --git a/src/redis-cli.c b/src/redis-cli.c index 3435c966..6ca4c372 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -787,7 +787,7 @@ static int cliSendCommand(int argc, char **argv, int repeat) { output_raw = 0; if (!strcasecmp(command,"info") || (argc >= 2 && !strcasecmp(command,"debug") && - (!strcasecmp(argv[1],"jemalloc") || + ((!strcasecmp(argv[1],"jemalloc") && !strcasecmp(argv[2],"info")) || !strcasecmp(argv[1],"htstats"))) || (argc == 2 && !strcasecmp(command,"cluster") && (!strcasecmp(argv[1],"nodes") ||