forked from memcached/memcached
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extstore: crawler fix and ext_low_ttl option
LRU crawler was not marking reclaimed expired items as removed from the storage engine. This could cause fragmentation to persist much longer than it should, but would not cause any problems once compaction started. Adds "ext_low_ttl" option. Items with a remaining expiration age below this value are grouped into special pages. If you have a mixed TTL workload this would help prevent low TTL items from causing excess fragmentation/compaction. Pages with low ttl items are excluded from compaction.
- Loading branch information
Showing
10 changed files
with
117 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
use Test::More; | ||
use FindBin qw($Bin); | ||
use lib "$Bin/lib"; | ||
use MemcachedTest; | ||
use Data::Dumper qw/Dumper/; | ||
|
||
my $ext_path; | ||
|
||
if (!supports_extstore()) { | ||
plan skip_all => 'extstore not enabled'; | ||
exit 0; | ||
} | ||
|
||
$ext_path = "/tmp/extstore.$$"; | ||
|
||
my $server = new_memcached("-m 64 -U 0 -o ext_page_size=8,ext_page_count=8,ext_wbuf_size=2,ext_threads=1,ext_io_depth=2,ext_item_size=512,ext_item_age=2,ext_recache_rate=10000,ext_max_frag=0,ext_path=$ext_path,ext_low_ttl=60"); | ||
my $sock = $server->sock; | ||
|
||
my $value; | ||
{ | ||
my @chars = ("C".."Z"); | ||
for (1 .. 20000) { | ||
$value .= $chars[rand @chars]; | ||
} | ||
} | ||
|
||
# fill some larger objects | ||
{ | ||
# interleave sets with 0 ttl vs long ttl's. | ||
my $keycount = 1200; | ||
for (1 .. $keycount) { | ||
print $sock "set nfoo$_ 0 0 20000 noreply\r\n$value\r\n"; | ||
print $sock "set lfoo$_ 0 5 20000 noreply\r\n$value\r\n"; | ||
} | ||
# wait for a flush | ||
sleep 10; | ||
print $sock "lru_crawler crawl all\r\n"; | ||
<$sock>; | ||
sleep 2; | ||
# fetch | ||
mem_get_is($sock, "nfoo1", $value); | ||
# check extstore counters | ||
my $stats = mem_stats($sock); | ||
cmp_ok($stats->{extstore_page_allocs}, '>', 0, 'at least one page allocated'); | ||
cmp_ok($stats->{extstore_objects_written}, '>', $keycount / 2, 'some objects written'); | ||
cmp_ok($stats->{extstore_bytes_written}, '>', length($value) * 2, 'some bytes written'); | ||
cmp_ok($stats->{get_extstore}, '>', 0, 'one object was fetched'); | ||
cmp_ok($stats->{extstore_objects_read}, '>', 0, 'one object read'); | ||
cmp_ok($stats->{extstore_bytes_read}, '>', length($value), 'some bytes read'); | ||
cmp_ok($stats->{extstore_page_reclaims}, '>', 1, 'at least two pages reclaimed'); | ||
} | ||
|
||
done_testing(); | ||
|
||
END { | ||
unlink $ext_path if $ext_path; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters