Changeset: 29e2d74ab2e8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/29e2d74ab2e8
Modified Files:
        gdk/gdk_system_private.h
        gdk/gdk_utils.c
Branch: Dec2025
Log Message:

Get rid of allocator freelist for full blocks.


diffs (137 lines):

diff --git a/gdk/gdk_system_private.h b/gdk/gdk_system_private.h
--- a/gdk/gdk_system_private.h
+++ b/gdk/gdk_system_private.h
@@ -60,9 +60,7 @@ struct allocator {
        size_t inuse;    /* number of objects in use*/
        size_t free_obj_hits; /* number of object reuse*/
        void *freelist; /* first free object */
-       void *freelist_blks;    /* first free blk */
        size_t frees;
-       size_t free_blk_hits;
        size_t tmp_used; /* counter for temp usage */
 
        int refcount;
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -2067,10 +2067,7 @@ ma_free_obj(allocator *sa, void *obj, si
                sa->inuse -= 1;
 }
 
-/*
- * Put regular blks of size MA_BLOCK_SIZE on freelist_blks
- * all others are GDKfree
- */
+
 static void
 ma_free_blk_memory(allocator *sa, void *blk)
 {
@@ -2078,15 +2075,8 @@ ma_free_blk_memory(allocator *sa, void *
                // all blks are GDKmalloc
                size_t sz = GDKmallocated(blk) - (MALLOC_EXTRA_SPACE + 
DEBUG_SPACE);
                assert(sz > 0);
-               if (sz == MA_BLOCK_SIZE) {
-                       freed_t *f = blk;
-                       f->sz = sz;
-                       f->n = sa->freelist_blks;
-                       sa->freelist_blks = f;
-               } else {
-                       GDKfree(blk);
-                       sa->usedmem -= sz;
-               }
+               GDKfree(blk);
+               sa->usedmem -= sz;
        }
 }
 
@@ -2149,41 +2139,11 @@ static int ma_double_num_blks(allocator 
  * Free blocks are maintained at top level
  */
 static void *
-ma_use_freed_blk(allocator *sa, size_t sz)
-{
-       if (sa->pa)
-               return ma_use_freed_blk(sa->pa, sz);
-       COND_LOCK_ALLOCATOR(sa);
-       if (sa->freelist_blks && (sz == MA_BLOCK_SIZE)) {
-               if (sa->nr >= sa->size && ma_double_num_blks(sa) < 0) {
-                       COND_UNLOCK_ALLOCATOR(sa);
-                       if (sa->eb.enabled)
-                               eb_error(&sa->eb, "out of memory", 1000);
-                       return NULL;
-               }
-               freed_t *f = sa->freelist_blks;
-               sa->freelist_blks = f->n;
-               sa->used = MA_BLOCK_SIZE;
-               sa->blks[sa->nr] = (void *) f;
-               sa->nr ++;
-               sa->free_blk_hits += 1;
-               COND_UNLOCK_ALLOCATOR(sa);
-               return f;
-       }
-       COND_UNLOCK_ALLOCATOR(sa);
-       return NULL;
-}
-
-
-static void *
 ma_use_freed(allocator *sa, size_t sz)
 {
        if (sz < MA_BLOCK_SIZE) {
                return ma_use_freed_obj(sa, sz);
        }
-       if (sz == MA_BLOCK_SIZE) {
-               return ma_use_freed_blk(sa, sz);
-       }
        return NULL;
 }
 
@@ -2255,8 +2215,6 @@ ma_reset(allocator *sa)
        sa->used = offset;
        sa->frees = 0;
        sa->nr = 1;
-       // reset freelist only i.e. leave freelist_blks alone as
-       // it may have blocks we can re-use
        sa->freelist = NULL;
        sa->usedmem = MA_BLOCK_SIZE;
        sa->objects = 0;
@@ -2424,13 +2382,11 @@ create_allocator(allocator *pa, const ch
                .nr = 1,
                .usedmem = MA_BLOCK_SIZE,
                .freelist = NULL,
-               .freelist_blks = NULL,
                .frees = 0,
                .used = offset,
                .objects = 0,
                .inuse = 0,
                .free_obj_hits = 0,
-               .free_blk_hits = 0,
                .tmp_used = 0,
                .refcount = 0,
                .use_lock = use_lock,
@@ -2481,11 +2437,6 @@ ma_destroy(allocator *sa)
                if (root_allocator) {
                        if (blks_relocated)
                                GDKfree(sa->blks);
-                       while (sa->freelist_blks) {
-                               freed_t *f = sa->freelist_blks;
-                               sa->freelist_blks = f->n;
-                               GDKfree(f);
-                       }
                        GDKfree(sa->first_blk);
                } else {
                        COND_LOCK_ALLOCATOR(sa->pa);
@@ -2671,13 +2622,6 @@ ma_info(allocator *a, char *buf, size_t 
                if (a->refcount > 0 && (size_t) pos < bufsize)
                        pos += snprintf(buf + pos, bufsize - pos,
                                        ", refcount %d", a->refcount);
-               size_t nfree = 0;
-               for (freed_t *f = a->freelist_blks; f; f = f->n)
-                       nfree++;
-               if (nfree > 0)
-                       pos += snprintf(buf + pos, bufsize - pos,
-                                       ", %zu block%s in freelist",
-                                       nfree, nfree == 1 ? "" : "s");
                COND_UNLOCK_ALLOCATOR(a);
        }
        return pos;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to