Commit 98d5d3f1 authored by antirez's avatar antirez
Browse files

Make active defragmentation tests optional.

They failed when active defrag could not be activated because the
Jemalloc version does not include the additional APIs.
parent fef42d09
...@@ -1031,9 +1031,10 @@ void configSetCommand(client *c) { ...@@ -1031,9 +1031,10 @@ void configSetCommand(client *c) {
if (server.active_defrag_enabled) { if (server.active_defrag_enabled) {
server.active_defrag_enabled = 0; server.active_defrag_enabled = 0;
addReplyError(c, addReplyError(c,
"Active defragmentation cannot be enabled: it requires a " "-DISABLED Active defragmentation cannot be enabled: it "
"Redis server compiled with a modified Jemalloc like the " "requires a Redis server compiled with a modified Jemalloc "
"one shipped by default with the Redis source distribution"); "like the one shipped by default with the Redis source "
"distribution");
return; return;
} }
#endif #endif
......
...@@ -55,31 +55,35 @@ start_server {tags {"defrag"}} { ...@@ -55,31 +55,35 @@ start_server {tags {"defrag"}} {
puts "frag $frag" puts "frag $frag"
} }
assert {$frag >= 1.4} assert {$frag >= 1.4}
r config set activedefrag yes catch {r config set activedefrag yes} e
if {![string match {DISABLED*} $e]} {
# Wait for the active defrag to start working (decision once a
# second).
wait_for_condition 50 100 {
[s active_defrag_running] ne 0
} else {
fail "defrag not started."
}
# wait for the active defrag to start working (decision once a second) # Wait for the active defrag to stop working.
wait_for_condition 50 100 { wait_for_condition 100 100 {
[s active_defrag_running] ne 0 [s active_defrag_running] eq 0
} else { } else {
fail "defrag not started." puts [r info memory]
} puts [r memory malloc-stats]
fail "defrag didn't stop."
}
# wait for the active defrag to stop working # Test the the fragmentation is lower.
wait_for_condition 100 100 { after 120 ;# serverCron only updates the info once in 100ms
[s active_defrag_running] eq 0 set frag [s allocator_frag_ratio]
if {$::verbose} {
puts "frag $frag"
}
assert {$frag < 1.1}
} else { } else {
puts [r info memory] set _ ""
puts [r memory malloc-stats]
fail "defrag didn't stop."
}
# test the the fragmentation is lower
after 120 ;# serverCron only updates the info once in 100ms
set frag [s allocator_frag_ratio]
if {$::verbose} {
puts "frag $frag"
} }
assert {$frag < 1.1}
} {} } {}
test "Active defrag big keys" { test "Active defrag big keys" {
...@@ -150,44 +154,48 @@ start_server {tags {"defrag"}} { ...@@ -150,44 +154,48 @@ start_server {tags {"defrag"}} {
assert {$frag >= $expected_frag} assert {$frag >= $expected_frag}
r config set latency-monitor-threshold 5 r config set latency-monitor-threshold 5
r latency reset r latency reset
r config set activedefrag yes
# wait for the active defrag to start working (decision once a second) catch {r config set activedefrag yes} e
wait_for_condition 50 100 { if {![string match {DISABLED*} $e]} {
[s active_defrag_running] ne 0 # wait for the active defrag to start working (decision once a second)
} else { wait_for_condition 50 100 {
fail "defrag not started." [s active_defrag_running] ne 0
} } else {
fail "defrag not started."
}
# wait for the active defrag to stop working # wait for the active defrag to stop working
wait_for_condition 500 100 { wait_for_condition 500 100 {
[s active_defrag_running] eq 0 [s active_defrag_running] eq 0
} else { } else {
puts [r info memory] puts [r info memory]
puts [r memory malloc-stats] puts [r memory malloc-stats]
fail "defrag didn't stop." fail "defrag didn't stop."
} }
# test the the fragmentation is lower # test the the fragmentation is lower
after 120 ;# serverCron only updates the info once in 100ms after 120 ;# serverCron only updates the info once in 100ms
set frag [s allocator_frag_ratio] set frag [s allocator_frag_ratio]
set max_latency 0 set max_latency 0
foreach event [r latency latest] { foreach event [r latency latest] {
lassign $event eventname time latency max lassign $event eventname time latency max
if {$eventname == "active-defrag-cycle"} { if {$eventname == "active-defrag-cycle"} {
set max_latency $max 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, 10hz, and active-defrag-cycle-max set to 75,
# we expect max latency to be not much higher than 75ms
assert {$max_latency <= 80}
} else {
set _ ""
} }
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, 10hz, and active-defrag-cycle-max set to 75,
# we expect max latency to be not much higher than 75ms
assert {$max_latency <= 80}
} {} } {}
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment