mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
add DEBUG JEMALLC PURGE and JEMALLOC INFO cleanup
This commit is contained in:
parent
7ba90225a0
commit
f8909a2579
17
src/debug.c
17
src/debug.c
@ -250,11 +250,13 @@ void computeDatasetDigest(unsigned char *final) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(USE_JEMALLOC)
|
||||||
void inputCatSds(void *result, const char *str) {
|
void inputCatSds(void *result, const char *str) {
|
||||||
/* result is actually a (sds *), so re-cast it here */
|
/* result is actually a (sds *), so re-cast it here */
|
||||||
sds *info = (sds *)result;
|
sds *info = (sds *)result;
|
||||||
*info = sdscat(*info, str);
|
*info = sdscat(*info, str);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void debugCommand(client *c) {
|
void debugCommand(client *c) {
|
||||||
if (!strcasecmp(c->argv[1]->ptr,"segfault")) {
|
if (!strcasecmp(c->argv[1]->ptr,"segfault")) {
|
||||||
@ -397,6 +399,7 @@ void debugCommand(client *c) {
|
|||||||
snprintf(buf,sizeof(buf),"value:%lu",j);
|
snprintf(buf,sizeof(buf),"value:%lu",j);
|
||||||
val = createStringObject(buf,strlen(buf));
|
val = createStringObject(buf,strlen(buf));
|
||||||
dbAdd(c->db,key,val);
|
dbAdd(c->db,key,val);
|
||||||
|
signalModifiedKey(c->db,key);
|
||||||
decrRefCount(key);
|
decrRefCount(key);
|
||||||
}
|
}
|
||||||
addReply(c,shared.ok);
|
addReply(c,shared.ok);
|
||||||
@ -474,8 +477,20 @@ void debugCommand(client *c) {
|
|||||||
sds info = sdsempty();
|
sds info = sdsempty();
|
||||||
je_malloc_stats_print(inputCatSds, &info, NULL);
|
je_malloc_stats_print(inputCatSds, &info, NULL);
|
||||||
addReplyBulkSds(c, info);
|
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 {
|
} else {
|
||||||
addReplyErrorFormat(c, "Valid jemalloc debug fields: info");
|
addReplyErrorFormat(c, "Valid jemalloc debug fields: info, purge");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
addReplyErrorFormat(c, "jemalloc support not available");
|
addReplyErrorFormat(c, "jemalloc support not available");
|
||||||
|
@ -787,7 +787,7 @@ static int cliSendCommand(int argc, char **argv, int repeat) {
|
|||||||
output_raw = 0;
|
output_raw = 0;
|
||||||
if (!strcasecmp(command,"info") ||
|
if (!strcasecmp(command,"info") ||
|
||||||
(argc >= 2 && !strcasecmp(command,"debug") &&
|
(argc >= 2 && !strcasecmp(command,"debug") &&
|
||||||
(!strcasecmp(argv[1],"jemalloc") ||
|
((!strcasecmp(argv[1],"jemalloc") && !strcasecmp(argv[2],"info")) ||
|
||||||
!strcasecmp(argv[1],"htstats"))) ||
|
!strcasecmp(argv[1],"htstats"))) ||
|
||||||
(argc == 2 && !strcasecmp(command,"cluster") &&
|
(argc == 2 && !strcasecmp(command,"cluster") &&
|
||||||
(!strcasecmp(argv[1],"nodes") ||
|
(!strcasecmp(argv[1],"nodes") ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user