Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't re-calculate the slab class id.

slabs_alloc() internally calls slabs_clsid(), so an eviction case would crawl the list of slab classes three times.


git-svn-id: http://code.sixapart.com/svn/memcached/trunk/server@738 b0b603af-a30f-0410-a34e-baf09ae79d0b
  • Loading branch information...
commit 01fa48f0bfd3a58a955d132059143af82847a911 1 parent e215d6c
@dormando dormando authored
Showing with 9 additions and 10 deletions.
  1. +2 −2 items.c
  2. +3 −3 memcached.h
  3. +1 −2  slabs.c
  4. +1 −1  slabs.h
  5. +2 −2 thread.c
View
4 items.c
@@ -88,7 +88,7 @@ item *do_item_alloc(char *key, const size_t nkey, const int flags, const rel_tim
if (id == 0)
return 0;
- it = slabs_alloc(ntotal);
+ it = slabs_alloc(ntotal, id);
if (it == 0) {
int tries = 50;
item *search;
@@ -119,7 +119,7 @@ item *do_item_alloc(char *key, const size_t nkey, const int flags, const rel_tim
break;
}
}
- it = slabs_alloc(ntotal);
+ it = slabs_alloc(ntotal, id);
if (it == 0) return NULL;
}
View
6 memcached.h
@@ -291,7 +291,7 @@ char *mt_item_stats_sizes(int *bytes);
void mt_item_unlink(item *it);
void mt_item_update(item *it);
void mt_run_deferred_deletes(void);
-void *mt_slabs_alloc(size_t size);
+void *mt_slabs_alloc(size_t size, unsigned int id);
void mt_slabs_free(void *ptr, size_t size);
int mt_slabs_reassign(unsigned char srcid, unsigned char dstid);
char *mt_slabs_stats(int *buflen);
@@ -320,7 +320,7 @@ int mt_store_item(item *item, int comm);
# define item_update(x) mt_item_update(x)
# define item_unlink(x) mt_item_unlink(x)
# define run_deferred_deletes() mt_run_deferred_deletes()
-# define slabs_alloc(x) mt_slabs_alloc(x)
+# define slabs_alloc(x,y) mt_slabs_alloc(x,y)
# define slabs_free(x,y) mt_slabs_free(x,y)
# define slabs_reassign(x,y) mt_slabs_reassign(x,y)
# define slabs_stats(x) mt_slabs_stats(x)
@@ -353,7 +353,7 @@ int mt_store_item(item *item, int comm);
# define item_unlink(x) do_item_unlink(x)
# define item_update(x) do_item_update(x)
# define run_deferred_deletes() do_run_deferred_deletes()
-# define slabs_alloc(x) do_slabs_alloc(x)
+# define slabs_alloc(x,y) do_slabs_alloc(x,y)
# define slabs_free(x,y) do_slabs_free(x,y)
# define slabs_reassign(x,y) do_slabs_reassign(x,y)
# define slabs_stats(x) do_slabs_stats(x)
View
3  slabs.c
@@ -218,10 +218,9 @@ static int do_slabs_newslab(const unsigned int id) {
}
/*@null@*/
-void *do_slabs_alloc(const size_t size) {
+void *do_slabs_alloc(const size_t size, unsigned int id) {
slabclass_t *p;
- unsigned int id = slabs_clsid(size);
if (id < POWER_SMALLEST || id > power_largest)
return NULL;
View
2  slabs.h
@@ -17,7 +17,7 @@ void slabs_init(const size_t limit, const double factor, const bool prealloc);
unsigned int slabs_clsid(const size_t size);
/** Allocate object of given length. 0 on error */ /*@null@*/
-void *do_slabs_alloc(const size_t size);
+void *do_slabs_alloc(const size_t size, unsigned int id);
/** Free previously allocated object */
void do_slabs_free(void *ptr, size_t size);
View
4 thread.c
@@ -571,11 +571,11 @@ void mt_assoc_move_next_bucket() {
/******************************* SLAB ALLOCATOR ******************************/
-void *mt_slabs_alloc(size_t size) {
+void *mt_slabs_alloc(size_t size, unsigned int id) {
void *ret;
pthread_mutex_lock(&slabs_lock);
- ret = do_slabs_alloc(size);
+ ret = do_slabs_alloc(size, id);
pthread_mutex_unlock(&slabs_lock);
return ret;
}

0 comments on commit 01fa48f

Please sign in to comment.
Something went wrong with that request. Please try again.