Changeset 745
- Timestamp:
- 03/03/08 07:51:02 (21 months ago)
- Location:
- branches/binary
- Files:
-
- 1 added
- 1 removed
- 10 modified
-
server/ChangeLog (modified) (1 diff)
-
server/configure.ac (modified) (1 diff)
-
server/doc/binary-protocol-plan.jpg (deleted)
-
server/doc/memcached.1 (modified) (1 diff)
-
server/items.c (modified) (9 diffs)
-
server/memcached.c (modified) (9 diffs)
-
server/memcached.h (modified) (3 diffs)
-
server/memcached.spec (modified) (1 diff)
-
server/slabs.c (modified) (2 diffs)
-
server/slabs.h (modified) (1 diff)
-
server/thread.c (modified) (1 diff)
-
website/dist/memcached-1.2.5-rc1.tar.gz (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/binary/server/ChangeLog
r722 r745 1 2008-03-02 [Version 1.2.5-rc1 released] 2 3 * Add per-item-class tracking of evictions and OOM errors (dormando) 4 5 * Optimize item_alloc() a little (dormando) 6 7 * Give 'SERVER_ERROR out of memory' errors more context (dormando) 8 9 * Enable usage of large memory pages under solaris 10 (Trond.Norbye@Sun.COM) 11 12 * Enable UDP by default, clean up server socket code 13 (brian@tangent.org) 14 1 15 * 'noreply' support (Tomash Brechko) 2 16 -
branches/binary/server/configure.ac
r725 r745 1 1 AC_PREREQ(2.52) 2 AC_INIT(memcached, 1.2. 4, brad@danga.com)2 AC_INIT(memcached, 1.2.5, brad@danga.com) 3 3 AC_CANONICAL_SYSTEM 4 4 AC_CONFIG_SRCDIR(memcached.c) -
branches/binary/server/doc/memcached.1
r629 r745 106 106 specified, stats collection is turned on automatically; if not, then it may 107 107 be turned on by sending the "stats detail on" command to the server. 108 .TP 109 .B \-L 110 Try to use large memory pages (if available). Increasing the memory page size 111 could reduce the number of TLB misses and improve the performance. In order to 112 get large pages from the OS, memcached will allocate the total item-cache in 113 one large chunk. Only available if supported on your OS. 108 114 .br 109 115 .SH LICENSE -
branches/binary/server/items.c
r642 r745 28 28 29 29 #define LARGEST_ID 255 30 typedef struct { 31 unsigned int evicted; 32 unsigned int outofmemory; 33 } itemstats_t; 34 30 35 static item *heads[LARGEST_ID]; 31 36 static item *tails[LARGEST_ID]; 37 static itemstats_t itemstats[LARGEST_ID]; 32 38 static unsigned int sizes[LARGEST_ID]; 33 39 34 40 void item_init(void) { 35 41 int i; 42 memset(itemstats, 0, sizeof(itemstats_t) * LARGEST_ID); 36 43 for(i = 0; i < LARGEST_ID; i++) { 37 44 heads[i] = NULL; … … 89 96 return 0; 90 97 91 it = slabs_alloc(ntotal );98 it = slabs_alloc(ntotal, id); 92 99 if (it == 0) { 93 100 int tries = 50; … … 98 105 */ 99 106 100 if (settings.evict_to_free == 0) return NULL; 107 if (settings.evict_to_free == 0) { 108 itemstats[id].outofmemory++; 109 return NULL; 110 } 101 111 102 112 /* … … 107 117 */ 108 118 109 if (id > LARGEST_ID) return NULL; 110 if (tails[id] == 0) return NULL; 119 if (tails[id] == 0) { 120 itemstats[id].outofmemory++; 121 return NULL; 122 } 111 123 112 124 for (search = tails[id]; tries > 0 && search != NULL; tries--, search=search->prev) { 113 125 if (search->refcount == 0) { 114 if (search->exptime == 0 || search->exptime > current_time) { 115 STATS_LOCK(); 116 stats.evictions++; 117 STATS_UNLOCK(); 126 if (search->exptime == 0 || search->exptime > current_time) { 127 itemstats[id].evicted++; 128 STATS_LOCK(); 129 stats.evictions++; 130 STATS_UNLOCK(); 118 131 } 119 132 do_item_unlink(search); … … 121 134 } 122 135 } 123 it = slabs_alloc(ntotal); 124 if (it == 0) return NULL; 136 it = slabs_alloc(ntotal, id); 137 if (it == 0) { 138 itemstats[id].outofmemory++; 139 return NULL; 140 } 125 141 } 126 142 … … 146 162 void item_free(item *it) { 147 163 size_t ntotal = ITEM_ntotal(it); 164 unsigned int clsid; 148 165 assert((it->it_flags & ITEM_LINKED) == 0); 149 166 assert(it != heads[it->slabs_clsid]); … … 152 169 153 170 /* so slab size changer can tell later if item is already free or not */ 171 clsid = it->slabs_clsid; 154 172 it->slabs_clsid = 0; 155 173 it->it_flags |= ITEM_SLABBED; 156 174 DEBUG_REFCNT(it, 'F'); 157 slabs_free(it, ntotal );175 slabs_free(it, ntotal, clsid); 158 176 } 159 177 … … 311 329 312 330 char *do_item_stats(int *bytes) { 313 size_t bufleft = (size_t) LARGEST_ID * 80;331 size_t bufleft = (size_t) LARGEST_ID * 160; 314 332 char *buffer = malloc(bufleft); 315 333 char *bufcurr = buffer; … … 324 342 for (i = 0; i < LARGEST_ID; i++) { 325 343 if (tails[i] != NULL) { 326 linelen = snprintf(bufcurr, bufleft, "STAT items:%d:number %u\r\nSTAT items:%d:age %u\r\n", 327 i, sizes[i], i, now - tails[i]->time); 344 linelen = snprintf(bufcurr, bufleft, 345 "STAT items:%d:number %u\r\n" 346 "STAT items:%d:age %u\r\n" 347 "STAT items:%d:evicted %u\r\n" 348 "STAT items:%d:outofmemory %u\r\n", 349 i, sizes[i], i, now - tails[i]->time, i, 350 itemstats[i].evicted, i, itemstats[i].outofmemory); 328 351 if (linelen + sizeof("END\r\n") < bufleft) { 329 352 bufcurr += linelen; -
branches/binary/server/memcached.c
r735 r745 1613 1613 c->write_and_go = get_init_state(c); 1614 1614 } else { 1615 out_string(c, "SERVER_ERROR out of memory ");1615 out_string(c, "SERVER_ERROR out of memory writing stats"); 1616 1616 } 1617 1617 } … … 1750 1750 1751 1751 if ((wbuf = (char *)malloc(wsize)) == NULL) { 1752 out_string(c, "SERVER_ERROR out of memory ");1752 out_string(c, "SERVER_ERROR out of memory writing stats maps"); 1753 1753 return; 1754 1754 } … … 1917 1917 stats.get_misses += stats_get_misses; 1918 1918 STATS_UNLOCK(); 1919 out_string(c, "SERVER_ERROR out of memory ");1919 out_string(c, "SERVER_ERROR out of memory making CAS suffix"); 1920 1920 return; 1921 1921 } … … 1986 1986 if (key_token->value != NULL || add_iov(c, "END\r\n", 5) != 0 1987 1987 || (IS_UDP(c->protocol) && build_udp_headers(c) != 0)) { 1988 out_string(c, "SERVER_ERROR out of memory ");1988 out_string(c, "SERVER_ERROR out of memory writing get response"); 1989 1989 } 1990 1990 else { … … 2061 2061 out_string(c, "SERVER_ERROR object too large for cache"); 2062 2062 else 2063 out_string(c, "SERVER_ERROR out of memory ");2063 out_string(c, "SERVER_ERROR out of memory storing object"); 2064 2064 /* swallow the data line */ 2065 2065 c->write_and_go = conn_swallow; … … 2164 2164 new_it = do_item_alloc(ITEM_key(it), it->nkey, atoi(ITEM_suffix(it) + 1), it->exptime, res + 2 ); 2165 2165 if (new_it == 0) { 2166 return "SERVER_ERROR out of memory ";2166 return "SERVER_ERROR out of memory in incr/decr"; 2167 2167 } 2168 2168 memcpy(ITEM_data(new_it), buf, res); … … 2255 2255 */ 2256 2256 item_remove(it); /* release reference */ 2257 return "SERVER_ERROR out of memory ";2257 return "SERVER_ERROR out of memory expanding delete queue"; 2258 2258 } 2259 2259 } … … 2300 2300 c->iovused = 0; 2301 2301 if (add_msghdr(c) != 0) { 2302 out_string(c, "SERVER_ERROR out of memory ");2302 out_string(c, "SERVER_ERROR out of memory preparing response"); 2303 2303 return; 2304 2304 } … … 2580 2580 fprintf(stderr, "Couldn't realloc input buffer\n"); 2581 2581 c->rbytes = 0; /* ignore what we read */ 2582 out_string(c, "SERVER_ERROR out of memory ");2582 out_string(c, "SERVER_ERROR out of memory reading request"); 2583 2583 c->write_and_go = conn_closing; 2584 2584 return 1; -
branches/binary/server/memcached.h
r733 r745 364 364 void mt_item_update(item *it); 365 365 void mt_run_deferred_deletes(void); 366 void *mt_slabs_alloc(size_t size );367 void mt_slabs_free(void *ptr, size_t size );366 void *mt_slabs_alloc(size_t size, unsigned int id); 367 void mt_slabs_free(void *ptr, size_t size, unsigned int id); 368 368 int mt_slabs_reassign(unsigned char srcid, unsigned char dstid); 369 369 char *mt_slabs_stats(int *buflen); … … 393 393 # define item_unlink(x) mt_item_unlink(x) 394 394 # define run_deferred_deletes() mt_run_deferred_deletes() 395 # define slabs_alloc(x ) mt_slabs_alloc(x)396 # define slabs_free(x,y ) mt_slabs_free(x,y)395 # define slabs_alloc(x,y) mt_slabs_alloc(x,y) 396 # define slabs_free(x,y,z) mt_slabs_free(x,y,z) 397 397 # define slabs_reassign(x,y) mt_slabs_reassign(x,y) 398 398 # define slabs_stats(x) mt_slabs_stats(x) … … 426 426 # define item_update(x) do_item_update(x) 427 427 # define run_deferred_deletes() do_run_deferred_deletes() 428 # define slabs_alloc(x ) do_slabs_alloc(x)429 # define slabs_free(x,y ) do_slabs_free(x,y)428 # define slabs_alloc(x,y) do_slabs_alloc(x,y) 429 # define slabs_free(x,y,z) do_slabs_free(x,y,z) 430 430 # define slabs_reassign(x,y) do_slabs_reassign(x,y) 431 431 # define slabs_stats(x) do_slabs_stats(x) -
branches/binary/server/memcached.spec
r648 r745 1 1 Name: memcached 2 Version: 1.2. 42 Version: 1.2.5 3 3 Release: 1%{?dist} 4 4 Summary: High Performance, Distributed Memory Object Cache -
branches/binary/server/slabs.c
r725 r745 219 219 220 220 /*@null@*/ 221 void *do_slabs_alloc(const size_t size ) {221 void *do_slabs_alloc(const size_t size, unsigned int id) { 222 222 slabclass_t *p; 223 223 224 unsigned int id = slabs_clsid(size);225 224 if (id < POWER_SMALLEST || id > power_largest) 226 225 return NULL; … … 259 258 } 260 259 261 void do_slabs_free(void *ptr, const size_t size) { 262 unsigned char id = slabs_clsid(size); 260 void do_slabs_free(void *ptr, const size_t size, unsigned int id) { 263 261 slabclass_t *p; 264 262 -
branches/binary/server/slabs.h
r725 r745 18 18 19 19 /** Allocate object of given length. 0 on error */ /*@null@*/ 20 void *do_slabs_alloc(const size_t size );20 void *do_slabs_alloc(const size_t size, unsigned int id); 21 21 22 22 /** Free previously allocated object */ 23 void do_slabs_free(void *ptr, size_t size );23 void do_slabs_free(void *ptr, size_t size, unsigned int id); 24 24 25 25 /** Fill buffer with stats */ /*@null@*/ -
branches/binary/server/thread.c
r672 r745 572 572 /******************************* SLAB ALLOCATOR ******************************/ 573 573 574 void *mt_slabs_alloc(size_t size ) {574 void *mt_slabs_alloc(size_t size, unsigned int id) { 575 575 void *ret; 576 576 577 577 pthread_mutex_lock(&slabs_lock); 578 ret = do_slabs_alloc(size );578 ret = do_slabs_alloc(size, id); 579 579 pthread_mutex_unlock(&slabs_lock); 580 580 return ret; 581 581 } 582 582 583 void mt_slabs_free(void *ptr, size_t size ) {583 void mt_slabs_free(void *ptr, size_t size, unsigned int id) { 584 584 pthread_mutex_lock(&slabs_lock); 585 do_slabs_free(ptr, size );585 do_slabs_free(ptr, size, id); 586 586 pthread_mutex_unlock(&slabs_lock); 587 587 }
