Skip to content

Commit 492ce51

Browse files
committed
Refactor of ActiveDefrag to reduce latencies
1 parent 1cd622b commit 492ce51

File tree

12 files changed

+653
-415
lines changed

12 files changed

+653
-415
lines changed

redis.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,6 +2297,11 @@ rdb-save-incremental-fsync yes
22972297
# the main dictionary scan
22982298
# active-defrag-max-scan-fields 1000
22992299

2300+
# The time spent (in microseconds) of the periodic active defrag process. This
2301+
# affects the latency impact of active defrag on client commands. Smaller numbers
2302+
# will result in less latency impact at the cost of increased defrag overhead.
2303+
# active-defrag-cycle-us 500
2304+
23002305
# Jemalloc background thread for purging will be enabled by default
23012306
jemalloc-bg-thread yes
23022307

src/ae.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ aeEventLoop *aeCreateEventLoop(int setsize) {
5656
if (eventLoop->events == NULL || eventLoop->fired == NULL) goto err;
5757
eventLoop->setsize = setsize;
5858
eventLoop->timeEventHead = NULL;
59-
eventLoop->timeEventNextId = 0;
59+
eventLoop->timeEventNextId = 1;
6060
eventLoop->stop = 0;
6161
eventLoop->maxfd = -1;
6262
eventLoop->beforesleep = NULL;

src/config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3172,6 +3172,7 @@ standardConfig static_configs[] = {
31723172
createIntConfig("active-defrag-cycle-max", NULL, MODIFIABLE_CONFIG, 1, 99, server.active_defrag_cycle_max, 25, INTEGER_CONFIG, NULL, updateDefragConfiguration), /* Default: 25% CPU max (at upper threshold) */
31733173
createIntConfig("active-defrag-threshold-lower", NULL, MODIFIABLE_CONFIG, 0, 1000, server.active_defrag_threshold_lower, 10, INTEGER_CONFIG, NULL, NULL), /* Default: don't defrag when fragmentation is below 10% */
31743174
createIntConfig("active-defrag-threshold-upper", NULL, MODIFIABLE_CONFIG, 0, 1000, server.active_defrag_threshold_upper, 100, INTEGER_CONFIG, NULL, updateDefragConfiguration), /* Default: maximum defrag force at 100% fragmentation */
3175+
createIntConfig("active-defrag-cycle-us", NULL, MODIFIABLE_CONFIG, 0, 100000, server.active_defrag_cycle_us, 500, INTEGER_CONFIG, NULL, updateDefragConfiguration),
31753176
createIntConfig("lfu-log-factor", NULL, MODIFIABLE_CONFIG, 0, INT_MAX, server.lfu_log_factor, 10, INTEGER_CONFIG, NULL, NULL),
31763177
createIntConfig("lfu-decay-time", NULL, MODIFIABLE_CONFIG, 0, INT_MAX, server.lfu_decay_time, 1, INTEGER_CONFIG, NULL, NULL),
31773178
createIntConfig("replica-priority", "slave-priority", MODIFIABLE_CONFIG, 0, INT_MAX, server.slave_priority, 100, INTEGER_CONFIG, NULL, NULL),

src/db.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,8 +2075,6 @@ static void deleteKeyAndPropagate(redisDb *db, robj *keyobj, int notify_type, lo
20752075
keyobj = createStringObject(keyobj->ptr, sdslen(keyobj->ptr));
20762076
}
20772077

2078-
serverLog(LL_DEBUG,"key %s %s: deleting it", (char*)keyobj->ptr, notify_type == NOTIFY_EXPIRED ? "expired" : "evicted");
2079-
20802078
/* We compute the amount of memory freed by db*Delete() alone.
20812079
* It is possible that actually the memory needed to propagate
20822080
* the DEL in AOF and replication link is greater than the one

0 commit comments

Comments
 (0)