summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2020-11-09 15:47:39 -0800
committerdormando <dormando@rydia.net>2020-11-20 12:19:56 -0800
commitb2cee81823ba32adf09a6666d92aee56a8d98056 (patch)
treec7e7fb4763106f2d8860eda60f34742e4f184f2f /t
parent2896cc6c49c2bcd064e00da8bdf0dcaf1a481e73 (diff)
downloadmemcached-b2cee81823ba32adf09a6666d92aee56a8d98056.tar.gz
item crawler hash table walk mode
specifying 'hash' instead of 'all' will make the LRU crawler iterate over ever bucket in the hash table once, instead of what's in the LRU. This also doesn't suffer from missing items because of LRU reordering or high lock contention.
Diffstat (limited to 't')
-rw-r--r--t/lru-crawler.t41
1 files changed, 39 insertions, 2 deletions
diff --git a/t/lru-crawler.t b/t/lru-crawler.t
index 2075236..eab2e6f 100644
--- a/t/lru-crawler.t
+++ b/t/lru-crawler.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More tests => 224;
+use Test::More tests => 70257;
use FindBin qw($Bin);
use lib "$Bin/lib";
use MemcachedTest;
@@ -77,7 +77,7 @@ while (1) {
/^(key=) (\S+).*([^\r\n]+)/;
$count++;
}
- is ($count, 60);
+ is ($count, 60, "metadump all returns all items");
}
for (1 .. 30) {
@@ -86,6 +86,43 @@ for (1 .. 30) {
mem_get_is($sock, "sfoo$_", undef);
}
+# add a few more items into a different slab class
+my $mfdata = 'x' x 512;
+for (1 .. 30) {
+ print $sock "set mfoo$_ 0 0 512\r\n$mfdata\r\n";
+ is(scalar <$sock>, "STORED\r\n", "stored key");
+}
+
+# set enough small values to ensure bucket chaining happens
+# ... but not enough that hash table expansion happens.
+# TODO: check hash power level?
+my %bfoo = ();
+for (1 .. 70000) {
+ print $sock "set bfoo$_ 0 0 1 noreply\r\nz\r\n";
+ $bfoo{$_} = 1;
+}
+{
+ print $sock "version\r\n";
+ my $res = <$sock>;
+ like($res, qr/^VERSION/, "bulk sets completed");
+}
+
+# Check metadump hash table walk returns correct number of items.
+{
+ print $sock "lru_crawler metadump hash\r\n";
+ my $count = 0;
+ while (<$sock>) {
+ last if /^(\.|END)/;
+ if (/^key=bfoo(\S+)/) {
+ ok(exists $bfoo{$1}, "found bfoo key $1 is still in test hash");
+ delete $bfoo{$1};
+ }
+ $count++;
+ }
+ is ($count, 70090, "metadump hash returns all items");
+ is ((keys %bfoo), 0, "metadump found all bfoo keys");
+}
+
print $sock "lru_crawler disable\r\n";
is(scalar <$sock>, "OK\r\n", "disabled lru crawler");
my $settings_match = 0;