Skip to content

Commit 1f26a94

Browse files
committed
Lazyfree: pending objects count in INFO output.
1 parent c69c6c8 commit 1f26a94

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/lazyfree.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
static size_t lazyfree_objects = 0;
77
pthread_mutex_t lazyfree_objects_mutex = PTHREAD_MUTEX_INITIALIZER;
88

9+
/* Return the number of currently pending objects to free. */
10+
size_t lazyfreeGetPendingObjectsCount(void) {
11+
return lazyfree_objects;
12+
}
13+
914
/* Return the amount of work needed in order to free an object.
1015
* The return value is not always the actual number of allocations the
1116
* object is compoesd of, but a number proportional to it.

src/server.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,7 +2803,8 @@ sds genRedisInfoString(char *section) {
28032803
"maxmemory_human:%s\r\n"
28042804
"maxmemory_policy:%s\r\n"
28052805
"mem_fragmentation_ratio:%.2f\r\n"
2806-
"mem_allocator:%s\r\n",
2806+
"mem_allocator:%s\r\n"
2807+
"lazyfree_pending_objects:%zu\r\n",
28072808
zmalloc_used,
28082809
hmem,
28092810
server.resident_set_size,
@@ -2818,7 +2819,8 @@ sds genRedisInfoString(char *section) {
28182819
maxmemory_hmem,
28192820
evict_policy,
28202821
zmalloc_get_fragmentation_ratio(server.resident_set_size),
2821-
ZMALLOC_LIB
2822+
ZMALLOC_LIB,
2823+
lazyfreeGetPendingObjectsCount()
28222824
);
28232825
}
28242826

src/server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,7 @@ void slotToKeyFlush(void);
14141414
int dbAsyncDelete(redisDb *db, robj *key);
14151415
void emptyDbAsync(redisDb *db);
14161416
void slotToKeyFlushAsync(void);
1417+
size_t lazyfreeGetPendingObjectsCount(void);
14171418

14181419
/* API to get key arguments from commands */
14191420
int *getKeysFromCommand(struct redisCommand *cmd, robj **argv, int argc, int *numkeys);

0 commit comments

Comments
 (0)