summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2012-07-14 22:05:18 -0700
committerdormando <dormando@rydia.net>2012-07-27 12:47:16 -0700
commit423b9fd4b51055eba2f6b6a374def446057308b6 (patch)
treeb469a7e220181b8902acd0c5b49dde469e082e51
parent845a4fe1c47d8ddfc330b8184c2cb5ceec8c0a69 (diff)
downloadmemcached-423b9fd4b51055eba2f6b6a374def446057308b6.tar.gz
remove end_page_ptr business from slabs
slab memory assignment used to lazily split a new page into chunks as memory was requested. now it doesn't, so drop all the related code. Cuts the memory assignment hotpath a tiny bit, so that's exciting.
-rw-r--r--memcached.c6
-rw-r--r--slabs.c33
-rw-r--r--slabs.h2
3 files changed, 6 insertions, 35 deletions
diff --git a/memcached.c b/memcached.c
index b121e16..e1ea9cd 100644
--- a/memcached.c
+++ b/memcached.c
@@ -3362,12 +3362,6 @@ static void process_command(conn *c, char *command) {
case REASSIGN_NOSPARE:
out_string(c, "NOSPARE source class has no spare pages");
break;
- case REASSIGN_DEST_NOT_FULL:
- out_string(c, "NOTFULL dest class has spare memory");
- break;
- case REASSIGN_SRC_NOT_SAFE:
- out_string(c, "UNSAFE src class is in an unsafe state");
- break;
case REASSIGN_SRC_DST_SAME:
out_string(c, "SAME src and dst class are identical");
break;
diff --git a/slabs.c b/slabs.c
index 4180f76..aa6061a 100644
--- a/slabs.c
+++ b/slabs.c
@@ -30,9 +30,6 @@ typedef struct {
void *slots; /* list of item ptrs */
unsigned int sl_curr; /* total free items in list */
- void *end_page_ptr; /* pointer to next free item at end of page, or 0 */
- unsigned int end_page_free; /* number of items remaining at end of last alloced page */
-
unsigned int slabs; /* how many slabs were allocated for this class */
void **slab_list; /* array of slab pointers */
@@ -215,8 +212,6 @@ static int do_slabs_newslab(const unsigned int id) {
memset(ptr, 0, (size_t)len);
split_slab_page_into_freelist(ptr, id);
-// p->end_page_ptr = ptr;
-// p->end_page_free = p->perslab;
p->slab_list[p->slabs++] = ptr;
mem_malloced += len;
@@ -252,8 +247,7 @@ static void *do_slabs_alloc(const size_t size, unsigned int id) {
/* fail unless we have space at the end of a recently allocated page,
we have something on our freelist, or we could allocate a new page */
- if (! (p->end_page_ptr != 0 || p->sl_curr != 0 ||
- do_slabs_newslab(id) != 0)) {
+ if (! (p->sl_curr != 0 || do_slabs_newslab(id) != 0)) {
/* We don't have more memory available */
ret = NULL;
} else if (p->sl_curr != 0) {
@@ -263,15 +257,6 @@ static void *do_slabs_alloc(const size_t size, unsigned int id) {
if (it->next) it->next->prev = 0;
p->sl_curr--;
ret = (void *)it;
- } else {
- /* if we recently allocated a whole page, return from that */
- assert(p->end_page_ptr != NULL);
- ret = p->end_page_ptr;
- if (--p->end_page_free != 0) {
- p->end_page_ptr = ((caddr_t)p->end_page_ptr) + p->size;
- } else {
- p->end_page_ptr = 0;
- }
}
if (ret) {
@@ -374,9 +359,10 @@ static void do_slabs_stats(ADD_STAT add_stats, void *c) {
APPEND_NUM_STAT(i, "total_pages", "%u", slabs);
APPEND_NUM_STAT(i, "total_chunks", "%u", slabs * perslab);
APPEND_NUM_STAT(i, "used_chunks", "%u",
- slabs*perslab - p->sl_curr - p->end_page_free);
+ slabs*perslab - p->sl_curr);
APPEND_NUM_STAT(i, "free_chunks", "%u", p->sl_curr);
- APPEND_NUM_STAT(i, "free_chunks_end", "%u", p->end_page_free);
+ /* Stat is dead, but displaying zero instead of removing it. */
+ APPEND_NUM_STAT(i, "free_chunks_end", "%u", 0);
APPEND_NUM_STAT(i, "mem_requested", "%llu",
(unsigned long long)p->requested);
APPEND_NUM_STAT(i, "get_hits", "%llu",
@@ -494,8 +480,7 @@ static int slab_rebalance_start(void) {
s_cls = &slabclass[slab_rebal.s_clsid];
d_cls = &slabclass[slab_rebal.d_clsid];
- if (d_cls->end_page_ptr || s_cls->end_page_ptr ||
- !grow_slab_list(slab_rebal.d_clsid)) {
+ if (!grow_slab_list(slab_rebal.d_clsid)) {
no_go = -1;
}
@@ -648,8 +633,6 @@ static void slab_rebalance_finish(void) {
d_cls->slab_list[d_cls->slabs++] = slab_rebal.slab_start;
split_slab_page_into_freelist(slab_rebal.slab_start,
slab_rebal.d_clsid);
-// d_cls->end_page_ptr = slab_rebal.slab_start;
-// d_cls->end_page_free = d_cls->perslab;
slab_rebal.done = 0;
slab_rebal.s_clsid = 0;
@@ -789,12 +772,6 @@ static enum reassign_result_type do_slabs_reassign(int src, int dst) {
if (slabclass[src].slabs < 2)
return REASSIGN_NOSPARE;
- if (slabclass[dst].end_page_ptr)
- return REASSIGN_DEST_NOT_FULL;
-
- if (slabclass[src].end_page_ptr)
- return REASSIGN_SRC_NOT_SAFE;
-
slab_rebal.s_clsid = src;
slab_rebal.d_clsid = dst;
diff --git a/slabs.h b/slabs.h
index 730474b..7c6140b 100644
--- a/slabs.h
+++ b/slabs.h
@@ -38,7 +38,7 @@ void stop_slab_maintenance_thread(void);
enum reassign_result_type {
REASSIGN_OK=0, REASSIGN_RUNNING, REASSIGN_BADCLASS, REASSIGN_NOSPARE,
- REASSIGN_DEST_NOT_FULL, REASSIGN_SRC_NOT_SAFE, REASSIGN_SRC_DST_SAME
+ REASSIGN_SRC_DST_SAME
};
enum reassign_result_type slabs_reassign(int src, int dst);