Permalink
Browse files

remove old unfinished slab reassignment code

Old code was unfinished, had no test coverage, and not quite what we'll end up
with in the future.

Slab reassignment will happen in earnest soon, but for now we should stop
confusing users.
  • Loading branch information...
1 parent bed5f9b commit c94c940ab2946b5878a1002a1656c634ece3d5e4 @dormando dormando committed with dustin Oct 7, 2009
Showing with 0 additions and 170 deletions.
  1. +0 −30 memcached.c
  2. +0 −38 scripts/memcached-tool
  3. +0 −85 slabs.c
  4. +0 −6 slabs.h
  5. +0 −11 t/slab-reassign.t
View
@@ -2801,36 +2801,6 @@ static void process_command(conn *c, char *command) {
conn_set_state(c, conn_closing);
- } else if (ntokens == 5 && (strcmp(tokens[COMMAND_TOKEN].value, "slabs") == 0 &&
- strcmp(tokens[COMMAND_TOKEN + 1].value, "reassign") == 0)) {
-#ifdef ALLOW_SLABS_REASSIGN
-
- int src, dst, rv;
-
- src = strtol(tokens[2].value, NULL, 10);
- dst = strtol(tokens[3].value, NULL, 10);
-
- if(errno == ERANGE) {
- out_string(c, "CLIENT_ERROR bad command line format");
- return;
- }
-
- rv = slabs_reassign(src, dst);
- if (rv == 1) {
- out_string(c, "DONE");
- return;
- }
- if (rv == 0) {
- out_string(c, "CANT");
- return;
- }
- if (rv == -1) {
- out_string(c, "BUSY");
- return;
- }
-#else
- out_string(c, "CLIENT_ERROR Slab reassignment not supported");
-#endif
} else if ((ntokens == 3 || ntokens == 4) && (strcmp(tokens[COMMAND_TOKEN].value, "verbosity") == 0)) {
process_verbosity_command(c, tokens, ntokens);
} else {
View
@@ -42,14 +42,6 @@ die
memcached-tool 10.0.0.5:11211 # same. (default is display)
memcached-tool 10.0.0.5:11211 stats # shows general stats
memcached-tool 10.0.0.5:11211 dump # dumps keys and values
- memcached-tool 10.0.0.5:11211 move 7 9 # takes 1MB slab from class #7
- # to class #9.
-
-You can only move slabs around on a server that supports 'slabs reassign'
-messages and only once slab memory is totally allocated, and only
-once the target class is full. (So you can't move from #6 to #9 and #7
-to #9 at the same itme, since you'd have to wait for #9 to fill from
-the first reassigned page)
" unless $host && $mode;
$host .= ":11211" unless $host =~ /:\d+/;
@@ -58,36 +50,6 @@ my $sock = IO::Socket::INET->new(PeerAddr => $host,
Proto => 'tcp');
die "Couldn't connect to $host\n" unless $sock;
-
-if ($mode eq "move") {
- my $tries = 0;
- while (1) {
- print $sock "slabs reassign $from $to\r\n";
- my $res = <$sock>;
- $res =~ s/\s+//;
- if ($res eq "DONE") {
- print "Success.\n";
- exit 0;
- } elsif ($res eq "CANT") {
- print "Error: can't move from $from to $to. Destination not yet full? See usage docs.\n";
- exit;
- } elsif ($res eq "BUSY") {
- if (++$tries == 3) {
- print "Failed to move after 3 tries. Try again later.\n";
- exit;
- }
-
- print "Page busy, retrying...\n";
- sleep 1;
- } elsif ($res =~ "CLIENT_ERROR") {
- print "Error: CLIENT_ERROR; perhaps slab reassignment is not enabled.\n";
- exit;
- }
- }
-
- exit;
-}
-
if ($mode eq 'dump') {
my %items;
my $totalitems;
View
85 slabs.c
@@ -196,11 +196,7 @@ static int grow_slab_list (const unsigned int id) {
static int do_slabs_newslab(const unsigned int id) {
slabclass_t *p = &slabclass[id];
-#ifdef ALLOW_SLABS_REASSIGN
- int len = settings.item_size_max;
-#else
int len = p->size * p->perslab;
-#endif
char *ptr;
if ((mem_limit && mem_malloced + len > mem_limit && p->slabs > 0) ||
@@ -393,87 +389,6 @@ static void do_slabs_stats(ADD_STAT add_stats, void *c) {
add_stats(NULL, 0, NULL, 0, c);
}
-#ifdef ALLOW_SLABS_REASSIGN
-/* Blows away all the items in a slab class and moves its slabs to another
- class. This is only used by the "slabs reassign" command, for manual tweaking
- of memory allocation. It's disabled by default since it requires that all
- slabs be the same size (which can waste space for chunk size mantissas of
- other than 2.0).
- 1 = success
- 0 = fail
- -1 = tried. busy. send again shortly. */
-int do_slabs_reassign(unsigned char srcid, unsigned char dstid) {
- void *slab, *slab_end;
- slabclass_t *p, *dp;
- void *iter;
- bool was_busy = false;
-
- if (srcid < POWER_SMALLEST || srcid > power_largest ||
- dstid < POWER_SMALLEST || dstid > power_largest)
- return 0;
-
- p = &slabclass[srcid];
- dp = &slabclass[dstid];
-
- /* fail if src still populating, or no slab to give up in src */
- if (p->end_page_ptr || ! p->slabs)
- return 0;
-
- /* fail if dst is still growing or we can't make room to hold its new one */
- if (dp->end_page_ptr || ! grow_slab_list(dstid))
- return 0;
-
- if (p->killing == 0) p->killing = 1;
-
- slab = p->slab_list[p->killing - 1];
- slab_end = (char*)slab + settings.item_size_max;
-
- for (iter = slab; iter < slab_end; (char*)iter += p->size) {
- item *it = (item *)iter;
- if (it->slabs_clsid) {
- if (it->refcount) was_busy = true;
- item_unlink(it);
- }
- }
-
- /* go through free list and discard items that are no longer part of this slab */
- {
- int fi;
- for (fi = p->sl_curr - 1; fi >= 0; fi--) {
- if (p->slots[fi] >= slab && p->slots[fi] < slab_end) {
- p->sl_curr--;
- if (p->sl_curr > fi) p->slots[fi] = p->slots[p->sl_curr];
- }
- }
- }
-
- if (was_busy) return -1;
-
- /* if good, now move it to the dst slab class */
- p->slab_list[p->killing - 1] = p->slab_list[p->slabs - 1];
- p->slabs--;
- p->killing = 0;
- dp->slab_list[dp->slabs++] = slab;
- dp->end_page_ptr = slab;
- dp->end_page_free = dp->perslab;
- /* this isn't too critical, but other parts of the code do asserts to
- make sure this field is always 0. */
- for (iter = slab; iter < slab_end; (char*)iter += dp->size) {
- ((item *)iter)->slabs_clsid = 0;
- }
- return 1;
-}
-
-int slabs_reassign(unsigned char srcid, unsigned char dstid) {
- int ret;
-
- pthread_mutex_lock(&slabs_lock);
- ret = do_slabs_reassign(srcid, dstid);
- pthread_mutex_unlock(&slabs_lock);
- return ret;
-}
-#endif
-
static void *memory_allocate(size_t size) {
void *ret;
View
@@ -30,10 +30,4 @@ bool get_stats(const char *stat_type, int nkey, ADD_STAT add_stats, void *c);
/** Fill buffer with stats */ /*@null@*/
void slabs_stats(ADD_STAT add_stats, void *c);
-/* Request some slab be moved between classes
- 1 = success
- 0 = fail
- -1 = tried. busy. send again shortly. */
-int slabs_reassign(unsigned char srcid, unsigned char dstid);
-
#endif
View
@@ -1,11 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use Test::More skip_all => "Tests not written."; # tests => 1
-use FindBin qw($Bin);
-use lib "$Bin/lib";
-use MemcachedTest;
-
-my $server = new_memcached();
-my $sock = $server->sock;
-

0 comments on commit c94c940

Please sign in to comment.