summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/mem-pool.c
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-11-09 05:14:22 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-11-09 03:07:03 -0800
commit667c5e22467cbecd371bfc052e7f65b6b6b41e2d (patch)
tree5add02895cf2ccc29c99da0f567485fc5a3b5bfa /libglusterfs/src/mem-pool.c
parent16eb9f73a5a7699d5c51d8139b4f1bc77ee3deda (diff)
libglusterfs: Memory accounting changes
This patch disables memory accounting by default and provides better alignemnt for faster fetch. Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 2068 (performance enhancements) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2068
Diffstat (limited to 'libglusterfs/src/mem-pool.c')
-rw-r--r--libglusterfs/src/mem-pool.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index 17d2e0dd2f1..76b62902317 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -29,15 +29,15 @@
#define mem_pool_ptr2chunkhead(ptr) ((ptr) - GF_MEM_POOL_PAD_BOUNDARY)
#define is_mem_chunk_in_use(ptr) (*ptr == 1)
-#define GF_MEM_HEADER_SIZE (4 + sizeof (size_t) + sizeof (xlator_t *) + 4)
-#define GF_MEM_TRAILER_SIZE 4
+#define GF_MEM_HEADER_SIZE (4 + sizeof (size_t) + sizeof (xlator_t *) + 4 + 8)
+#define GF_MEM_TRAILER_SIZE 8
#define GF_MEM_HEADER_MAGIC 0xCAFEBABE
#define GF_MEM_TRAILER_MAGIC 0xBAADF00D
#define GLUSTERFS_ENV_MEM_ACCT_STR "GLUSTERFS_DISABLE_MEM_ACCT"
-static int gf_mem_acct_enable = 1;
+static int gf_mem_acct_enable = 0;
int
gf_mem_acct_is_enabled ()
@@ -110,6 +110,7 @@ gf_mem_set_acct_info (xlator_t *xl, char **alloc_ptr,
ptr += sizeof (xlator_t *);
*(uint32_t *)(ptr) = GF_MEM_HEADER_MAGIC;
ptr = ptr + 4;
+ ptr = ptr + 8; //padding
*(uint32_t *) (ptr + size) = GF_MEM_TRAILER_MAGIC;
*alloc_ptr = (void *)ptr;
@@ -174,10 +175,12 @@ __gf_realloc (void *ptr, size_t size)
xlator_t *xl = NULL;
uint32_t type = 0;
+ if (!gf_mem_acct_enable)
+ return realloc (ptr, size);
tot_size = size + GF_MEM_HEADER_SIZE + GF_MEM_TRAILER_SIZE;
- orig_ptr = (char *)ptr - 4;
+ orig_ptr = (char *)ptr - 8 - 4;
GF_ASSERT (*(uint32_t *)orig_ptr == GF_MEM_HEADER_MAGIC);
@@ -256,8 +259,7 @@ __gf_free (void *free_ptr)
if (!free_ptr)
return;
-
- ptr = (char *)free_ptr - 4;
+ ptr = (char *)free_ptr - 8 - 4;
if (GF_MEM_HEADER_MAGIC != *(uint32_t *)ptr) {
//Possible corruption, assert here