summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2020-02-23 12:46:14 +0200
committerOran Agra <oran@redislabs.com>2020-02-23 13:05:52 +0200
commit62adabd0e0935cbb1cdedb3cde012c50ad1356a1 (patch)
tree906096a93bc5da67f799c1600b250627fc89d683 /tests
parente78c4e813cecfa97505efe29c073f8088542f69e (diff)
downloadredis-62adabd0e0935cbb1cdedb3cde012c50ad1356a1.tar.gz
Fix latency sensitivity of new defrag test
I saw that the new defag test for list was failing in CI recently, so i reduce it's threshold from 12 to 60. besides that, i add / improve the latency test for that other two defrag tests (add a sensitive latency and digest / save checks) and fix bad usage of debug populate (can't overrides existing keys). this was the original intention, which creates higher fragmentation.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/memefficiency.tcl40
1 files changed, 32 insertions, 8 deletions
diff --git a/tests/unit/memefficiency.tcl b/tests/unit/memefficiency.tcl
index ec80c7384..468825a47 100644
--- a/tests/unit/memefficiency.tcl
+++ b/tests/unit/memefficiency.tcl
@@ -39,6 +39,8 @@ start_server {tags {"memefficiency"}} {
start_server {tags {"defrag"}} {
if {[string match {*jemalloc*} [s mem_allocator]]} {
test "Active defrag" {
+ r config set save "" ;# prevent bgsave from interfereing with save below
+ r config set hz 100
r config set activedefrag no
r config set active-defrag-threshold-lower 5
r config set active-defrag-cycle-min 65
@@ -46,8 +48,8 @@ start_server {tags {"defrag"}} {
r config set active-defrag-ignore-bytes 2mb
r config set maxmemory 100mb
r config set maxmemory-policy allkeys-lru
- r debug populate 700000 asdf 150
- r debug populate 170000 asdf 300
+ r debug populate 700000 asdf1 150
+ r debug populate 170000 asdf2 300
r ping ;# trigger eviction following the previous population
after 120 ;# serverCron only updates the info once in 100ms
set frag [s allocator_frag_ratio]
@@ -55,6 +57,10 @@ start_server {tags {"defrag"}} {
puts "frag $frag"
}
assert {$frag >= 1.4}
+
+ r config set latency-monitor-threshold 5
+ r latency reset
+ set digest [r debug digest]
catch {r config set activedefrag yes} e
if {![string match {DISABLED*} $e]} {
# Wait for the active defrag to start working (decision once a
@@ -78,19 +84,37 @@ start_server {tags {"defrag"}} {
# Test the the fragmentation is lower.
after 120 ;# serverCron only updates the info once in 100ms
set frag [s allocator_frag_ratio]
+ set max_latency 0
+ foreach event [r latency latest] {
+ lassign $event eventname time latency max
+ if {$eventname == "active-defrag-cycle"} {
+ set max_latency $max
+ }
+ }
if {$::verbose} {
puts "frag $frag"
+ puts "max latency $max_latency"
+ puts [r latency latest]
+ puts [r latency history active-defrag-cycle]
}
assert {$frag < 1.1}
+ # due to high fragmentation, 100hz, and active-defrag-cycle-max set to 75,
+ # we expect max latency to be not much higher than 7.5ms but due to rare slowness threshold is set higher
+ assert {$max_latency <= 60}
} else {
set _ ""
}
- } {}
+ # verify the data isn't corrupted or changed
+ set newdigest [r debug digest]
+ assert {$digest eq $newdigest}
+ r save ;# saving an rdb iterates over all the data / pointers
+ } {OK}
test "Active defrag big keys" {
r flushdb
r config resetstat
r config set save "" ;# prevent bgsave from interfereing with save below
+ r config set hz 100
r config set activedefrag no
r config set active-defrag-max-scan-fields 1000
r config set active-defrag-threshold-lower 5
@@ -200,9 +224,9 @@ start_server {tags {"defrag"}} {
puts [r latency history active-defrag-cycle]
}
assert {$frag < 1.1}
- # due to high fragmentation, 10hz, and active-defrag-cycle-max set to 75,
- # we expect max latency to be not much higher than 75ms
- assert {$max_latency <= 120}
+ # due to high fragmentation, 100hz, and active-defrag-cycle-max set to 75,
+ # we expect max latency to be not much higher than 7.5ms but due to rare slowness threshold is set higher
+ assert {$max_latency <= 60}
}
# verify the data isn't corrupted or changed
set newdigest [r debug digest]
@@ -292,8 +316,8 @@ start_server {tags {"defrag"}} {
}
assert {$frag < 1.1}
# due to high fragmentation, 100hz, and active-defrag-cycle-max set to 75,
- # we expect max latency to be not much higher than 7.5ms
- assert {$max_latency <= 12}
+ # we expect max latency to be not much higher than 7.5ms but due to rare slowness threshold is set higher
+ assert {$max_latency <= 60}
}
# verify the data isn't corrupted or changed
set newdigest [r debug digest]