Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
319a6831
Commit
319a6831
authored
Feb 24, 2020
by
antirez
Browse files
Merge branch 'unstable' of github.com:/antirez/redis into unstable
parents
07acdd4a
3fbb41ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/unit/memefficiency.tcl
View file @
319a6831
...
@@ -39,6 +39,8 @@ start_server {tags {"memefficiency"}} {
...
@@ -39,6 +39,8 @@ start_server {tags {"memefficiency"}} {
start_server
{
tags
{
"defrag"
}}
{
start_server
{
tags
{
"defrag"
}}
{
if
{[
string match
{
*jemalloc*
}
[
s mem_allocator
]]}
{
if
{[
string match
{
*jemalloc*
}
[
s mem_allocator
]]}
{
test
"Active defrag"
{
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 activedefrag no
r config set active-defrag-threshold-lower 5
r config set active-defrag-threshold-lower 5
r config set active-defrag-cycle-min 65
r config set active-defrag-cycle-min 65
...
@@ -46,8 +48,8 @@ start_server {tags {"defrag"}} {
...
@@ -46,8 +48,8 @@ start_server {tags {"defrag"}} {
r config set active-defrag-ignore-bytes 2mb
r config set active-defrag-ignore-bytes 2mb
r config set maxmemory 100mb
r config set maxmemory 100mb
r config set maxmemory-policy allkeys-lru
r config set maxmemory-policy allkeys-lru
r debug populate 700000 asdf 150
r debug populate 700000 asdf
1
150
r debug populate 170000 asdf 300
r debug populate 170000 asdf
2
300
r ping
;
# trigger eviction following the previous population
r ping
;
# trigger eviction following the previous population
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
]
...
@@ -55,6 +57,10 @@ start_server {tags {"defrag"}} {
...
@@ -55,6 +57,10 @@ start_server {tags {"defrag"}} {
puts
"frag
$frag
"
puts
"frag
$frag
"
}
}
assert
{
$frag
>= 1.4
}
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
catch
{
r config set activedefrag yes
}
e
if
{
!
[
string match
{
DISABLED*
}
$e
]}
{
if
{
!
[
string match
{
DISABLED*
}
$e
]}
{
# Wait for the active defrag to start working
(
decision once a
# Wait for the active defrag to start working
(
decision once a
...
@@ -78,19 +84,37 @@ start_server {tags {"defrag"}} {
...
@@ -78,19 +84,37 @@ start_server {tags {"defrag"}} {
# 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
foreach event
[
r latency latest
]
{
lassign $event eventname time latency max
if
{
$eventname
==
"active-defrag-cycle"
}
{
set max_latency $max
}
}
if
{
$::verbose
}
{
if
{
$::verbose
}
{
puts
"frag
$frag
"
puts
"frag
$frag
"
puts
"max latency
$max
_latency"
puts
[
r latency latest
]
puts
[
r latency history active-defrag-cycle
]
}
}
assert
{
$frag
< 1.1
}
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
{
}
else
{
set _
""
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"
{
test
"Active defrag big keys"
{
r flushdb
r flushdb
r config resetstat
r config resetstat
r config set save
""
;
# prevent bgsave from interfereing with save below
r config set save
""
;
# prevent bgsave from interfereing with save below
r config set hz 100
r config set activedefrag no
r config set activedefrag no
r config set active-defrag-max-scan-fields 1000
r config set active-defrag-max-scan-fields 1000
r config set active-defrag-threshold-lower 5
r config set active-defrag-threshold-lower 5
...
@@ -200,9 +224,9 @@ start_server {tags {"defrag"}} {
...
@@ -200,9 +224,9 @@ start_server {tags {"defrag"}} {
puts
[
r latency history active-defrag-cycle
]
puts
[
r latency history active-defrag-cycle
]
}
}
assert
{
$frag
< 1.1
}
assert
{
$frag
< 1.1
}
# due to high fragmentation, 10hz, and active-defrag-cycle-max set to 75,
# due to high fragmentation, 10
0
hz, and active-defrag-cycle-max set to 75,
# we expect max latency to be not much higher than 75ms
# we expect max latency to be not much higher than 7
.
5ms
but due to rare slowness threshold is set higher
assert
{
$max
_latency <=
12
0
}
assert
{
$max
_latency <=
6
0
}
}
}
# verify the data isn't corrupted or changed
# verify the data isn't corrupted or changed
set newdigest
[
r debug digest
]
set newdigest
[
r debug digest
]
...
@@ -292,8 +316,8 @@ start_server {tags {"defrag"}} {
...
@@ -292,8 +316,8 @@ start_server {tags {"defrag"}} {
}
}
assert
{
$frag
< 1.1
}
assert
{
$frag
< 1.1
}
# due to high fragmentation, 100hz, and active-defrag-cycle-max set to 75,
# 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
# we expect max latency to be not much higher than 7.5ms
but due to rare slowness threshold is set higher
assert
{
$max
_latency <=
12
}
assert
{
$max
_latency <=
60
}
}
}
# verify the data isn't corrupted or changed
# verify the data isn't corrupted or changed
set newdigest
[
r debug digest
]
set newdigest
[
r debug digest
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment