Skip to content

Commit 70624ea

Browse files
authored
Change all the lazyfree configurations to yes by default (#913)
## 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. ## Set lazy eviction, expire, server-del, user-del to yes by default We now have a del and a lazyfree del, we also have these configuration items to control: lazyfree-lazy-eviction, lazyfree-lazy-expire, lazyfree-lazy-server-del, lazyfree-lazy-user-del. In most cases lazyfree is better since it reduces the risk of blocking the main thread, and because we have lazyfreeGetFreeEffort, on those with high effor (currently 64) will use lazyfree. Part of #653. --------- Signed-off-by: Binbin <[email protected]>
1 parent 089048d commit 70624ea

File tree

11 files changed

+60
-55
lines changed

11 files changed

+60
-55
lines changed

src/config.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3067,11 +3067,11 @@ standardConfig static_configs[] = {
30673067
createBoolConfig("stop-writes-on-bgsave-error", NULL, MODIFIABLE_CONFIG, server.stop_writes_on_bgsave_err, 1, NULL, NULL),
30683068
createBoolConfig("set-proc-title", NULL, IMMUTABLE_CONFIG, server.set_proc_title, 1, NULL, NULL), /* Should setproctitle be used? */
30693069
createBoolConfig("dynamic-hz", NULL, MODIFIABLE_CONFIG, server.dynamic_hz, 1, NULL, NULL), /* Adapt hz to # of clients.*/
3070-
createBoolConfig("lazyfree-lazy-eviction", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_eviction, 0, NULL, NULL),
3071-
createBoolConfig("lazyfree-lazy-expire", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_expire, 0, NULL, NULL),
3072-
createBoolConfig("lazyfree-lazy-server-del", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_server_del, 0, NULL, NULL),
3073-
createBoolConfig("lazyfree-lazy-user-del", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_user_del, 0, NULL, NULL),
3074-
createBoolConfig("lazyfree-lazy-user-flush", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_user_flush, 0, NULL, NULL),
3070+
createBoolConfig("lazyfree-lazy-eviction", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_eviction, 1, NULL, NULL),
3071+
createBoolConfig("lazyfree-lazy-expire", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_expire, 1, NULL, NULL),
3072+
createBoolConfig("lazyfree-lazy-server-del", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_server_del, 1, NULL, NULL),
3073+
createBoolConfig("lazyfree-lazy-user-del", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_user_del, 1, NULL, NULL),
3074+
createBoolConfig("lazyfree-lazy-user-flush", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_user_flush, 1, NULL, NULL),
30753075
createBoolConfig("repl-disable-tcp-nodelay", NULL, MODIFIABLE_CONFIG, server.repl_disable_tcp_nodelay, 0, NULL, NULL),
30763076
createBoolConfig("repl-diskless-sync", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.repl_diskless_sync, 1, NULL, NULL),
30773077
createBoolConfig("dual-channel-replication-enabled", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.dual_channel_replication, 0, NULL, NULL),
@@ -3083,7 +3083,7 @@ standardConfig static_configs[] = {
30833083
createBoolConfig("aof-use-rdb-preamble", NULL, MODIFIABLE_CONFIG, server.aof_use_rdb_preamble, 1, NULL, NULL),
30843084
createBoolConfig("aof-timestamp-enabled", NULL, MODIFIABLE_CONFIG, server.aof_timestamp_enabled, 0, NULL, NULL),
30853085
createBoolConfig("cluster-replica-no-failover", "cluster-slave-no-failover", MODIFIABLE_CONFIG, server.cluster_replica_no_failover, 0, NULL, updateClusterFlags), /* Failover by default. */
3086-
createBoolConfig("replica-lazy-flush", "slave-lazy-flush", MODIFIABLE_CONFIG, server.repl_replica_lazy_flush, 0, NULL, NULL),
3086+
createBoolConfig("replica-lazy-flush", "slave-lazy-flush", MODIFIABLE_CONFIG, server.repl_replica_lazy_flush, 1, NULL, NULL),
30873087
createBoolConfig("replica-serve-stale-data", "slave-serve-stale-data", MODIFIABLE_CONFIG, server.repl_serve_stale_data, 1, NULL, NULL),
30883088
createBoolConfig("replica-read-only", "slave-read-only", DEBUG_CONFIG | MODIFIABLE_CONFIG, server.repl_replica_ro, 1, NULL, NULL),
30893089
createBoolConfig("replica-ignore-maxmemory", "slave-ignore-maxmemory", MODIFIABLE_CONFIG, server.repl_replica_ignore_maxmemory, 1, NULL, NULL),

tests/unit/expire.tcl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ start_server {tags {"expire"}} {
368368
{set foo10 bar}
369369
{pexpireat foo10 *}
370370
{set foo11 bar}
371-
{del foo11}
371+
{unlink foo11}
372372
{set foo12 bar}
373373
{pexpireat foo12 *}
374374
{set foo13 bar}
@@ -500,7 +500,7 @@ start_server {tags {"expire"}} {
500500
{set foo3 bar}
501501
{pexpireat foo3 *}
502502
{pexpireat foo3 *}
503-
{del foo3}
503+
{unlink foo3}
504504
{set foo4 bar}
505505
{pexpireat foo4 *}
506506
{pexpireat foo4 *}
@@ -629,7 +629,7 @@ start_server {tags {"expire"}} {
629629
r ttl foo
630630
} {-1} {needs:debug}
631631

632-
test {GETEX propagate as to replica as PERSIST, DEL, or nothing} {
632+
test {GETEX propagate as to replica as PERSIST, UNLINK, or nothing} {
633633
# In the above tests, many keys with random expiration times are set, flush
634634
# the DBs to avoid active expiry kicking in and messing the replication streams.
635635
r flushall
@@ -642,7 +642,7 @@ start_server {tags {"expire"}} {
642642
{select *}
643643
{set foo bar PXAT *}
644644
{persist foo}
645-
{del foo}
645+
{unlink foo}
646646
}
647647
close_replication_stream $repl
648648
} {} {needs:repl}
@@ -784,7 +784,7 @@ start_server {tags {"expire"}} {
784784

785785
assert_replication_stream $repl {
786786
{select *}
787-
{del foo}
787+
{unlink foo}
788788
{set x 1}
789789
}
790790
close_replication_stream $repl
@@ -805,8 +805,8 @@ start_server {tags {"expire"}} {
805805

806806
assert_replication_stream $repl {
807807
{select *}
808-
{del foo*}
809-
{del foo*}
808+
{unlink foo*}
809+
{unlink foo*}
810810
}
811811
close_replication_stream $repl
812812
assert_equal [r debug set-active-expire 1] {OK}
@@ -826,8 +826,8 @@ start_server {tags {"expire"}} {
826826

827827
assert_replication_stream $repl {
828828
{select *}
829-
{del foo*}
830-
{del foo*}
829+
{unlink foo*}
830+
{unlink foo*}
831831
}
832832
close_replication_stream $repl
833833
assert_equal [r debug set-active-expire 1] {OK}

tests/unit/latency-monitor.tcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ tags {"needs:debug"} {
144144

145145
test {LATENCY of expire events are correctly collected} {
146146
r config set latency-monitor-threshold 20
147+
r config set lazyfree-lazy-expire no
147148
r flushdb
148149
if {$::valgrind} {set count 100000} else {set count 1000000}
149150
r eval {
@@ -166,6 +167,7 @@ tags {"needs:debug"} {
166167
}
167168

168169
r config set latency-monitor-threshold 200
170+
r config set lazyfree-lazy-expire yes
169171
}
170172

171173
test {LATENCY HISTORY / RESET with wrong event name is fine} {

tests/unit/maxmemory.tcl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,9 @@ start_server {tags {"maxmemory" "external:skip"}} {
550550
{set asdf1 1}
551551
{set asdf2 2}
552552
{set asdf3 3}
553-
{del asdf*}
554-
{del asdf*}
555-
{del asdf*}
553+
{unlink asdf*}
554+
{unlink asdf*}
555+
{unlink asdf*}
556556
{set asdf4 4}
557557
}
558558
close_replication_stream $repl
@@ -586,7 +586,7 @@ start_server {tags {"maxmemory" "external:skip"}} {
586586
{incr x}
587587
{incr x}
588588
{exec}
589-
{del x}
589+
{unlink x}
590590
}
591591
close_replication_stream $repl
592592

tests/unit/memefficiency.tcl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ run_solo {defrag} {
178178
r config set key-load-delay 0
179179

180180
test "Active defrag eval scripts: $type" {
181-
r flushdb
181+
r flushdb sync
182182
r script flush sync
183183
r config resetstat
184184
r config set hz 100
@@ -264,7 +264,7 @@ run_solo {defrag} {
264264
} {OK}
265265

266266
test "Active defrag big keys: $type" {
267-
r flushdb
267+
r flushdb sync
268268
r config resetstat
269269
r config set hz 100
270270
r config set activedefrag no
@@ -405,7 +405,7 @@ run_solo {defrag} {
405405
} {OK}
406406

407407
test "Active defrag pubsub: $type" {
408-
r flushdb
408+
r flushdb sync
409409
r config resetstat
410410
r config set hz 100
411411
r config set activedefrag no
@@ -505,7 +505,7 @@ run_solo {defrag} {
505505

506506
if {$type eq "standalone"} { ;# skip in cluster mode
507507
test "Active defrag big list: $type" {
508-
r flushdb
508+
r flushdb sync
509509
r config resetstat
510510
r config set hz 100
511511
r config set activedefrag no
@@ -617,7 +617,7 @@ run_solo {defrag} {
617617
# kept running and not move any allocation.
618618
# this test is more consistent on a fresh server with no history
619619
start_server {tags {"defrag"} overrides {save ""}} {
620-
r flushdb
620+
r flushdb sync
621621
r config resetstat
622622
r config set hz 100
623623
r config set activedefrag no

tests/unit/moduleapi/async_rm_call.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ start_server {tags {"modules"}} {
374374
#
375375
# Explanation of the second multi exec block:
376376
# {lpop l} - pop the value by our blocking command 'blpop_and_set_multiple_keys'
377-
# {del string_foo} - lazy expiration of string_foo when 'blpop_and_set_multiple_keys' tries to write to it.
377+
# {unlink string_foo} - lazy expiration of string_foo when 'blpop_and_set_multiple_keys' tries to write to it.
378378
# {set string_foo 1} - the action of our blocking command 'blpop_and_set_multiple_keys'
379379
# {set string_bar 2} - the action of our blocking command 'blpop_and_set_multiple_keys'
380380
# {incr expired} - the post notification job, registered after string_foo got expired
@@ -398,7 +398,7 @@ start_server {tags {"modules"}} {
398398
{lpush l a}
399399
{multi}
400400
{lpop l}
401-
{del string_foo}
401+
{unlink string_foo}
402402
{set string_foo 1}
403403
{set string_bar 2}
404404
{incr expired}

tests/unit/moduleapi/cluster.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ start_cluster 2 2 [list config_lines $modules] {
210210
# the {lpush before_deleted count_dels_{4oi}} is a post notification job registered when 'count_dels_{4oi}' was removed
211211
assert_replication_stream $repl {
212212
{multi}
213-
{del count_dels_{4oi}}
213+
{unlink count_dels_{4oi}}
214214
{keyspace.incr_dels}
215215
{lpush before_deleted count_dels_{4oi}}
216216
{exec}

tests/unit/moduleapi/postnotifications.tcl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ tags "modules" {
7272
{set x 1}
7373
{pexpireat x *}
7474
{multi}
75-
{del x}
75+
{unlink x}
7676
{lpush before_expired x}
7777
{incr expired}
7878
{exec}
@@ -96,7 +96,7 @@ tags "modules" {
9696
{set x 1}
9797
{pexpireat x *}
9898
{multi}
99-
{del x}
99+
{unlink x}
100100
{lpush before_expired x}
101101
{incr expired}
102102
{exec}
@@ -122,7 +122,7 @@ tags "modules" {
122122
{pexpireat x *}
123123
{multi}
124124
{set read_x 1}
125-
{del x}
125+
{unlink x}
126126
{lpush before_expired x}
127127
{incr expired}
128128
{exec}
@@ -162,7 +162,7 @@ tags "modules" {
162162
{select *}
163163
{set x 1}
164164
{multi}
165-
{del x}
165+
{unlink x}
166166
{lpush before_evicted x}
167167
{incr evicted}
168168
{exec}

tests/unit/moduleapi/propagate.tcl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,19 @@ tags "modules" {
112112
{incr notifications}
113113
{incr notifications}
114114
{incr testkeyspace:expired}
115-
{del asdf*}
115+
{unlink asdf*}
116116
{exec}
117117
{multi}
118118
{incr notifications}
119119
{incr notifications}
120120
{incr testkeyspace:expired}
121-
{del asdf*}
121+
{unlink asdf*}
122122
{exec}
123123
{multi}
124124
{incr notifications}
125125
{incr notifications}
126126
{incr testkeyspace:expired}
127-
{del asdf*}
127+
{unlink asdf*}
128128
{exec}
129129
}
130130
close_replication_stream $repl
@@ -211,15 +211,15 @@ tags "modules" {
211211
{exec}
212212
{multi}
213213
{incr notifications}
214-
{del asdf*}
214+
{unlink asdf*}
215215
{exec}
216216
{multi}
217217
{incr notifications}
218-
{del asdf*}
218+
{unlink asdf*}
219219
{exec}
220220
{multi}
221221
{incr notifications}
222-
{del asdf*}
222+
{unlink asdf*}
223223
{exec}
224224
{multi}
225225
{incr notifications}
@@ -257,11 +257,11 @@ tags "modules" {
257257
{exec}
258258
{multi}
259259
{incr notifications}
260-
{del timer-maxmemory-volatile-*}
260+
{unlink timer-maxmemory-volatile-*}
261261
{exec}
262262
{multi}
263263
{incr notifications}
264-
{del timer-maxmemory-volatile-*}
264+
{unlink timer-maxmemory-volatile-*}
265265
{exec}
266266
}
267267
close_replication_stream $repl
@@ -588,7 +588,7 @@ tags "modules" {
588588
assert_replication_stream $repl {
589589
{multi}
590590
{select *}
591-
{del k1}
591+
{unlink k1}
592592
{propagate-test.incr k1}
593593
{exec}
594594
}
@@ -619,9 +619,9 @@ tags "modules" {
619619
fail "Failed to wait for set to be replicated"
620620
}
621621

622-
# Currently the `del` command comes after the notification.
622+
# Currently the `unlink` command comes after the notification.
623623
# When we fix spop to fire notification at the end (like all other commands),
624-
# the `del` will come first.
624+
# the `unlink` will come first.
625625
assert_replication_stream $repl {
626626
{multi}
627627
{select *}
@@ -631,7 +631,7 @@ tags "modules" {
631631
{multi}
632632
{incr notifications}
633633
{incr notifications}
634-
{del s}
634+
{unlink s}
635635
{exec}
636636
}
637637
close_replication_stream $repl

tests/unit/type/list.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} {
11761176
{swapdb 1 9}
11771177
{select 9}
11781178
{set somekey1 someval1}
1179-
{del k}
1179+
{unlink k}
11801180
{select 1}
11811181
{set somekey2 someval2}
11821182
}
@@ -1220,7 +1220,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} {
12201220
{rpush k hello}
12211221
{pexpireat k *}
12221222
{exec}
1223-
{del k}
1223+
{unlink k}
12241224
}
12251225
close_replication_stream $repl
12261226
# Restore server and client state

0 commit comments

Comments
 (0)