Skip to content

Commit c94c940

Browse files
dormandodustin
authored andcommitted
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.
1 parent bed5f9b commit c94c940

File tree

5 files changed

+0
-170
lines changed

5 files changed

+0
-170
lines changed

memcached.c

-30
Original file line numberDiff line numberDiff line change
@@ -2801,36 +2801,6 @@ static void process_command(conn *c, char *command) {
28012801

28022802
conn_set_state(c, conn_closing);
28032803

2804-
} else if (ntokens == 5 && (strcmp(tokens[COMMAND_TOKEN].value, "slabs") == 0 &&
2805-
strcmp(tokens[COMMAND_TOKEN + 1].value, "reassign") == 0)) {
2806-
#ifdef ALLOW_SLABS_REASSIGN
2807-
2808-
int src, dst, rv;
2809-
2810-
src = strtol(tokens[2].value, NULL, 10);
2811-
dst = strtol(tokens[3].value, NULL, 10);
2812-
2813-
if(errno == ERANGE) {
2814-
out_string(c, "CLIENT_ERROR bad command line format");
2815-
return;
2816-
}
2817-
2818-
rv = slabs_reassign(src, dst);
2819-
if (rv == 1) {
2820-
out_string(c, "DONE");
2821-
return;
2822-
}
2823-
if (rv == 0) {
2824-
out_string(c, "CANT");
2825-
return;
2826-
}
2827-
if (rv == -1) {
2828-
out_string(c, "BUSY");
2829-
return;
2830-
}
2831-
#else
2832-
out_string(c, "CLIENT_ERROR Slab reassignment not supported");
2833-
#endif
28342804
} else if ((ntokens == 3 || ntokens == 4) && (strcmp(tokens[COMMAND_TOKEN].value, "verbosity") == 0)) {
28352805
process_verbosity_command(c, tokens, ntokens);
28362806
} else {

scripts/memcached-tool

-38
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,6 @@ die
4242
memcached-tool 10.0.0.5:11211 # same. (default is display)
4343
memcached-tool 10.0.0.5:11211 stats # shows general stats
4444
memcached-tool 10.0.0.5:11211 dump # dumps keys and values
45-
memcached-tool 10.0.0.5:11211 move 7 9 # takes 1MB slab from class #7
46-
# to class #9.
47-
48-
You can only move slabs around on a server that supports 'slabs reassign'
49-
messages and only once slab memory is totally allocated, and only
50-
once the target class is full. (So you can't move from #6 to #9 and #7
51-
to #9 at the same itme, since you'd have to wait for #9 to fill from
52-
the first reassigned page)
5345
" unless $host && $mode;
5446

5547
$host .= ":11211" unless $host =~ /:\d+/;
@@ -58,36 +50,6 @@ my $sock = IO::Socket::INET->new(PeerAddr => $host,
5850
Proto => 'tcp');
5951
die "Couldn't connect to $host\n" unless $sock;
6052

61-
62-
if ($mode eq "move") {
63-
my $tries = 0;
64-
while (1) {
65-
print $sock "slabs reassign $from $to\r\n";
66-
my $res = <$sock>;
67-
$res =~ s/\s+//;
68-
if ($res eq "DONE") {
69-
print "Success.\n";
70-
exit 0;
71-
} elsif ($res eq "CANT") {
72-
print "Error: can't move from $from to $to. Destination not yet full? See usage docs.\n";
73-
exit;
74-
} elsif ($res eq "BUSY") {
75-
if (++$tries == 3) {
76-
print "Failed to move after 3 tries. Try again later.\n";
77-
exit;
78-
}
79-
80-
print "Page busy, retrying...\n";
81-
sleep 1;
82-
} elsif ($res =~ "CLIENT_ERROR") {
83-
print "Error: CLIENT_ERROR; perhaps slab reassignment is not enabled.\n";
84-
exit;
85-
}
86-
}
87-
88-
exit;
89-
}
90-
9153
if ($mode eq 'dump') {
9254
my %items;
9355
my $totalitems;

slabs.c

-85
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,7 @@ static int grow_slab_list (const unsigned int id) {
196196

197197
static int do_slabs_newslab(const unsigned int id) {
198198
slabclass_t *p = &slabclass[id];
199-
#ifdef ALLOW_SLABS_REASSIGN
200-
int len = settings.item_size_max;
201-
#else
202199
int len = p->size * p->perslab;
203-
#endif
204200
char *ptr;
205201

206202
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) {
393389
add_stats(NULL, 0, NULL, 0, c);
394390
}
395391

396-
#ifdef ALLOW_SLABS_REASSIGN
397-
/* Blows away all the items in a slab class and moves its slabs to another
398-
class. This is only used by the "slabs reassign" command, for manual tweaking
399-
of memory allocation. It's disabled by default since it requires that all
400-
slabs be the same size (which can waste space for chunk size mantissas of
401-
other than 2.0).
402-
1 = success
403-
0 = fail
404-
-1 = tried. busy. send again shortly. */
405-
int do_slabs_reassign(unsigned char srcid, unsigned char dstid) {
406-
void *slab, *slab_end;
407-
slabclass_t *p, *dp;
408-
void *iter;
409-
bool was_busy = false;
410-
411-
if (srcid < POWER_SMALLEST || srcid > power_largest ||
412-
dstid < POWER_SMALLEST || dstid > power_largest)
413-
return 0;
414-
415-
p = &slabclass[srcid];
416-
dp = &slabclass[dstid];
417-
418-
/* fail if src still populating, or no slab to give up in src */
419-
if (p->end_page_ptr || ! p->slabs)
420-
return 0;
421-
422-
/* fail if dst is still growing or we can't make room to hold its new one */
423-
if (dp->end_page_ptr || ! grow_slab_list(dstid))
424-
return 0;
425-
426-
if (p->killing == 0) p->killing = 1;
427-
428-
slab = p->slab_list[p->killing - 1];
429-
slab_end = (char*)slab + settings.item_size_max;
430-
431-
for (iter = slab; iter < slab_end; (char*)iter += p->size) {
432-
item *it = (item *)iter;
433-
if (it->slabs_clsid) {
434-
if (it->refcount) was_busy = true;
435-
item_unlink(it);
436-
}
437-
}
438-
439-
/* go through free list and discard items that are no longer part of this slab */
440-
{
441-
int fi;
442-
for (fi = p->sl_curr - 1; fi >= 0; fi--) {
443-
if (p->slots[fi] >= slab && p->slots[fi] < slab_end) {
444-
p->sl_curr--;
445-
if (p->sl_curr > fi) p->slots[fi] = p->slots[p->sl_curr];
446-
}
447-
}
448-
}
449-
450-
if (was_busy) return -1;
451-
452-
/* if good, now move it to the dst slab class */
453-
p->slab_list[p->killing - 1] = p->slab_list[p->slabs - 1];
454-
p->slabs--;
455-
p->killing = 0;
456-
dp->slab_list[dp->slabs++] = slab;
457-
dp->end_page_ptr = slab;
458-
dp->end_page_free = dp->perslab;
459-
/* this isn't too critical, but other parts of the code do asserts to
460-
make sure this field is always 0. */
461-
for (iter = slab; iter < slab_end; (char*)iter += dp->size) {
462-
((item *)iter)->slabs_clsid = 0;
463-
}
464-
return 1;
465-
}
466-
467-
int slabs_reassign(unsigned char srcid, unsigned char dstid) {
468-
int ret;
469-
470-
pthread_mutex_lock(&slabs_lock);
471-
ret = do_slabs_reassign(srcid, dstid);
472-
pthread_mutex_unlock(&slabs_lock);
473-
return ret;
474-
}
475-
#endif
476-
477392
static void *memory_allocate(size_t size) {
478393
void *ret;
479394

slabs.h

-6
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,4 @@ bool get_stats(const char *stat_type, int nkey, ADD_STAT add_stats, void *c);
3030
/** Fill buffer with stats */ /*@null@*/
3131
void slabs_stats(ADD_STAT add_stats, void *c);
3232

33-
/* Request some slab be moved between classes
34-
1 = success
35-
0 = fail
36-
-1 = tried. busy. send again shortly. */
37-
int slabs_reassign(unsigned char srcid, unsigned char dstid);
38-
3933
#endif

t/slab-reassign.t

-11
This file was deleted.

0 commit comments

Comments
 (0)