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
0fb5c4eb
Commit
0fb5c4eb
authored
Jan 30, 2017
by
oranagra
Committed by
antirez
Apr 22, 2017
Browse files
add test for active defrag
parent
e3b8492e
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/unit/memefficiency.tcl
View file @
0fb5c4eb
...
@@ -35,3 +35,48 @@ start_server {tags {"memefficiency"}} {
...
@@ -35,3 +35,48 @@ start_server {tags {"memefficiency"}} {
}
}
}
}
}
}
start_server
{
tags
{
"defrag"
}}
{
if
{[
string match
{
*jemalloc*
}
[
s mem_allocator
]]}
{
test
"Actove defrag"
{
r config set activedefrag no
r config set active-defrag-threshold-lower 5
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
set frag
[
s mem_fragmentation_ratio
]
assert
{
$frag
>= 1.7
}
r config set activedefrag yes
after 1500
;
# active defrag tests the status once a second.
set hits
[
s active_defrag_hits
]
# wait for the active defrag to stop working
set tries 0
while
{
True
}
{
incr tries
after 500
set prev_hits $hits
set hits
[
s active_defrag_hits
]
if
{
$hits
== $prev_hits
}
{
break
}
assert
{
$tries
< 100
}
}
# TODO: we need to expose more accurate fragmentation info
# i.e. the allocator used and active pages
# instead we currently look at RSS so we need to ask for purge
r memory purge
# test the the fragmentation is lower and that the defragger stopped working
set frag
[
s mem_fragmentation_ratio
]
assert
{
$frag
< 1.4
}
set misses
[
s active_defrag_misses
]
after 500
set misses2
[
s active_defrag_misses
]
assert
{
$misses2
== $misses
}
}
}
}
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