Large memory support
Jason Titus
jtitus@postini.com
Fri, 20 Feb 2004 09:19:02 -0800
Did I give you what you needed for the large memory patch? We are using =
it now and it seems to work well w/ caches of 4GB and more. Should be =
clean as well since the size_t type will still be 32 bits on 32 bit =
architectures.
Did you still need a script to fill up a cache with more than 2GB of =
data?
Let me know if I need to get you anything else.
Thanks for the great tool,
Jason
p.s. - here is a cleaner patch I made with 'diff -c -b -r =
memcached-1.1.10 memcached-bigmem-1.1.10/'
--------
diff -c -b -r memcached-1.1.10/memcached.c =
memcached-bigmem-1.1.10/memcached.c
*** memcached-1.1.10/memcached.c 2003-12-04 09:50:57.000000000 =
-0800
--- memcached-bigmem-1.1.10/memcached.c 2004-02-18 23:27:39.000000000 =
-0800
***************
*** 336,342 ****
pos +=3D sprintf(pos, "STAT get_misses %u\r\n", =
stats.get_misses);
pos +=3D sprintf(pos, "STAT bytes_read %llu\r\n", =
stats.bytes_read);
pos +=3D sprintf(pos, "STAT bytes_written %llu\r\n", =
stats.bytes_written);
! pos +=3D sprintf(pos, "STAT limit_maxbytes %u\r\n", =
settings.maxbytes);
pos +=3D sprintf(pos, "END");
out_string(c, temp);
return;
--- 336,342 ----
pos +=3D sprintf(pos, "STAT get_misses %u\r\n", =
stats.get_misses);
pos +=3D sprintf(pos, "STAT bytes_read %llu\r\n", =
stats.bytes_read);
pos +=3D sprintf(pos, "STAT bytes_written %llu\r\n", =
stats.bytes_written);
! pos +=3D sprintf(pos, "STAT limit_maxbytes %llu\r\n", =
settings.maxbytes);
pos +=3D sprintf(pos, "END");
out_string(c, temp);
return;
***************
*** 1279,1285 ****
settings.port =3D atoi(optarg);
break;
case 'm':
! settings.maxbytes =3D atoi(optarg)*1024*1024;
break;
case 'c':
settings.maxconns =3D atoi(optarg);
--- 1279,1285 ----
settings.port =3D atoi(optarg);
break;
case 'm':
! settings.maxbytes =3D (size_t) atoi(optarg)* (size_t) =
1024* (size_t) 1024;
break;
case 'c':
settings.maxconns =3D atoi(optarg);
diff -c -b -r memcached-1.1.10/memcached.h =
memcached-bigmem-1.1.10/memcached.h
*** memcached-1.1.10/memcached.h 2003-12-04 09:50:57.000000000 =
-0800
--- memcached-bigmem-1.1.10/memcached.h 2004-02-18 23:11:28.000000000 =
-0800
***************
*** 10,16 ****
struct stats {
unsigned int curr_items;
unsigned int total_items;
! unsigned long long curr_bytes;
unsigned int curr_conns;
unsigned int total_conns;
unsigned int conn_structs;
--- 10,16 ----
struct stats {
unsigned int curr_items;
unsigned int total_items;
! size_t curr_bytes;
unsigned int curr_conns;
unsigned int total_conns;
unsigned int conn_structs;
***************
*** 24,30 ****
};
=20
struct settings {
! unsigned int maxbytes;
int maxconns;
int port;
struct in_addr interface;
--- 24,30 ----
};
=20
struct settings {
! size_t maxbytes;
int maxconns;
int port;
struct in_addr interface;
***************
*** 147,163 ****
/* slabs memory allocation */
=20
/* Init the subsystem. The argument is the limit on no. of bytes to =
allocate, 0 if no limit */
! void slabs_init(unsigned int limit);
=20
/* Given object size, return id to use when allocating/freeing memory =
for object */
/* 0 means error: can't store such a large object */
! unsigned int slabs_clsid(unsigned int size);
=20
/* Allocate object of given length. 0 on error */
! void *slabs_alloc(unsigned int size);
=20
/* Free previously allocated object */
! void slabs_free(void *ptr, unsigned int size);
=20
/* Fill buffer with stats */
char* slabs_stats(int *buflen);
--- 147,163 ----
/* slabs memory allocation */
=20
/* Init the subsystem. The argument is the limit on no. of bytes to =
allocate, 0 if no limit */
! void slabs_init(size_t limit);
=20
/* Given object size, return id to use when allocating/freeing memory =
for object */
/* 0 means error: can't store such a large object */
! unsigned int slabs_clsid(size_t size);
=20
/* Allocate object of given length. 0 on error */
! void *slabs_alloc(size_t size);
=20
/* Free previously allocated object */
! void slabs_free(void *ptr, size_t size);
=20
/* Fill buffer with stats */
char* slabs_stats(int *buflen);
Only in memcached-bigmem-1.1.10/: mem.log
diff -c -b -r memcached-1.1.10/slabs.c memcached-bigmem-1.1.10/slabs.c
*** memcached-1.1.10/slabs.c 2003-09-05 15:37:36.000000000 -0700
--- memcached-bigmem-1.1.10/slabs.c 2004-02-18 23:08:52.000000000 =
-0800
***************
*** 49,58 ****
} slabclass_t;
=20
static slabclass_t slabclass[POWER_LARGEST+1];
! static unsigned int mem_limit =3D 0;
! static unsigned int mem_malloced =3D 0;
=20
! unsigned int slabs_clsid(unsigned int size) {
int res =3D 1;
=20
if(size=3D=3D0)
--- 49,58 ----
} slabclass_t;
=20
static slabclass_t slabclass[POWER_LARGEST+1];
! static size_t mem_limit =3D 0;
! static size_t mem_malloced =3D 0;
=20
! unsigned int slabs_clsid(size_t size) {
int res =3D 1;
=20
if(size=3D=3D0)
***************
*** 67,73 ****
return res;
}
=20
! void slabs_init(unsigned int limit) {
int i;
int size=3D1;
=20
--- 67,73 ----
return res;
}
=20
! void slabs_init(size_t limit) {
int i;
int size=3D1;
=20
***************
*** 88,94 ****
static int grow_slab_list (unsigned int id) {=20
slabclass_t *p =3D &slabclass[id];
if (p->slabs =3D=3D p->list_size) {
! unsigned int new_size =3D p->list_size ? p->list_size * 2 : =
16;
void *new_list =3D realloc(p->slab_list, =
new_size*sizeof(void*));
if (new_list =3D=3D 0) return 0;
p->list_size =3D new_size;
--- 88,94 ----
static int grow_slab_list (unsigned int id) {=20
slabclass_t *p =3D &slabclass[id];
if (p->slabs =3D=3D p->list_size) {
! size_t new_size =3D p->list_size ? p->list_size * 2 : 16;
void *new_list =3D realloc(p->slab_list, =
new_size*sizeof(void*));
if (new_list =3D=3D 0) return 0;
p->list_size =3D new_size;
***************
*** 120,126 ****
return 1;
}
=20
! void *slabs_alloc(unsigned int size) {
slabclass_t *p;
=20
unsigned char id =3D slabs_clsid(size);
--- 120,126 ----
return 1;
}
=20
! void *slabs_alloc(size_t size) {
slabclass_t *p;
=20
unsigned char id =3D slabs_clsid(size);
***************
*** 160,166 ****
return 0; /* shouldn't ever get here */
}
=20
! void slabs_free(void *ptr, unsigned int size) {
unsigned char id =3D slabs_clsid(size);
slabclass_t *p;
=20
--- 160,166 ----
return 0; /* shouldn't ever get here */
}
=20
! void slabs_free(void *ptr, size_t size) {
unsigned char id =3D slabs_clsid(size);
slabclass_t *p;
=20
Only in memcached-bigmem-1.1.10/: stamp-h