From 0afbe071745024dcf9a812591075f99a4b3e18d8 Mon Sep 17 00:00:00 2001 From: Binbin Date: Wed, 14 Aug 2024 22:19:18 +0800 Subject: [PATCH] Set replica-lazy-flush and lazyfree-lazy-user-flush to yes by default There are many problems with running flush synchronously. Even in single CPU environments, the thread managers should balance between the freeing and serving incoming requests. Signed-off-by: Binbin --- src/config.c | 4 ++-- tests/unit/memefficiency.tcl | 10 +++++----- valkey.conf | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/config.c b/src/config.c index afac82be6d..89383a3039 100644 --- a/src/config.c +++ b/src/config.c @@ -3071,7 +3071,7 @@ standardConfig static_configs[] = { createBoolConfig("lazyfree-lazy-expire", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_expire, 0, NULL, NULL), createBoolConfig("lazyfree-lazy-server-del", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_server_del, 0, NULL, NULL), createBoolConfig("lazyfree-lazy-user-del", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_user_del, 0, NULL, NULL), - createBoolConfig("lazyfree-lazy-user-flush", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_user_flush, 0, NULL, NULL), + createBoolConfig("lazyfree-lazy-user-flush", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_user_flush, 1, NULL, NULL), createBoolConfig("repl-disable-tcp-nodelay", NULL, MODIFIABLE_CONFIG, server.repl_disable_tcp_nodelay, 0, NULL, NULL), createBoolConfig("repl-diskless-sync", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.repl_diskless_sync, 1, NULL, NULL), createBoolConfig("dual-channel-replication-enabled", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG | PROTECTED_CONFIG, server.dual_channel_replication, 0, NULL, NULL), @@ -3083,7 +3083,7 @@ standardConfig static_configs[] = { createBoolConfig("aof-use-rdb-preamble", NULL, MODIFIABLE_CONFIG, server.aof_use_rdb_preamble, 1, NULL, NULL), createBoolConfig("aof-timestamp-enabled", NULL, MODIFIABLE_CONFIG, server.aof_timestamp_enabled, 0, NULL, NULL), createBoolConfig("cluster-replica-no-failover", "cluster-slave-no-failover", MODIFIABLE_CONFIG, server.cluster_replica_no_failover, 0, NULL, updateClusterFlags), /* Failover by default. */ - createBoolConfig("replica-lazy-flush", "slave-lazy-flush", MODIFIABLE_CONFIG, server.repl_replica_lazy_flush, 0, NULL, NULL), + createBoolConfig("replica-lazy-flush", "slave-lazy-flush", MODIFIABLE_CONFIG, server.repl_replica_lazy_flush, 1, NULL, NULL), createBoolConfig("replica-serve-stale-data", "slave-serve-stale-data", MODIFIABLE_CONFIG, server.repl_serve_stale_data, 1, NULL, NULL), createBoolConfig("replica-read-only", "slave-read-only", DEBUG_CONFIG | MODIFIABLE_CONFIG, server.repl_replica_ro, 1, NULL, NULL), createBoolConfig("replica-ignore-maxmemory", "slave-ignore-maxmemory", MODIFIABLE_CONFIG, server.repl_replica_ignore_maxmemory, 1, NULL, NULL), diff --git a/tests/unit/memefficiency.tcl b/tests/unit/memefficiency.tcl index feb98d9cdd..89b5b2096a 100644 --- a/tests/unit/memefficiency.tcl +++ b/tests/unit/memefficiency.tcl @@ -178,7 +178,7 @@ run_solo {defrag} { r config set key-load-delay 0 test "Active defrag eval scripts: $type" { - r flushdb + r flushdb sync r script flush sync r config resetstat r config set hz 100 @@ -264,7 +264,7 @@ run_solo {defrag} { } {OK} test "Active defrag big keys: $type" { - r flushdb + r flushdb sync r config resetstat r config set hz 100 r config set activedefrag no @@ -407,7 +407,7 @@ run_solo {defrag} { # Skip the following two tests if we are running with IO threads, as the IO threads allocate the command arguments in a different arena. As a result, fragmentation is not as expected. if {[r config get io-threads] eq 0} { test "Active defrag pubsub: $type" { - r flushdb + r flushdb sync r config resetstat r config set hz 100 r config set activedefrag no @@ -508,7 +508,7 @@ run_solo {defrag} { if {$type eq "standalone"} { ;# skip in cluster mode test "Active defrag big list: $type" { - r flushdb + r flushdb sync r config resetstat r config set hz 100 r config set activedefrag no @@ -620,7 +620,7 @@ run_solo {defrag} { # kept running and not move any allocation. # this test is more consistent on a fresh server with no history start_server {tags {"defrag"} overrides {save ""}} { - r flushdb + r flushdb sync r config resetstat r config set hz 100 r config set activedefrag no diff --git a/valkey.conf b/valkey.conf index 68f4ad1f72..c76e0df515 100644 --- a/valkey.conf +++ b/valkey.conf @@ -1279,7 +1279,7 @@ acllog-max-len 128 lazyfree-lazy-eviction no lazyfree-lazy-expire no lazyfree-lazy-server-del no -replica-lazy-flush no +replica-lazy-flush yes # It is also possible, for the case when to replace the user code DEL calls # with UNLINK calls is not easy, to modify the default behavior of the DEL @@ -1293,7 +1293,7 @@ lazyfree-lazy-user-del no # commands. When neither flag is passed, this directive will be used to determine # if the data should be deleted asynchronously. -lazyfree-lazy-user-flush no +lazyfree-lazy-user-flush yes ################################ THREADED I/O #################################