changeset 5216:9b8c2168d231

Allocate lrecord arrays in own size class.
author Marcus Crestani <crestani@informatik.uni-tuebingen.de>
date Sat, 29 May 2010 07:10:49 +0200
parents 956d54c39176
children c0f518284a68
files src/ChangeLog src/mc-alloc.c
diffstat 2 files changed, 74 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri May 28 13:52:16 2010 +0100
+++ b/src/ChangeLog	Sat May 29 07:10:49 2010 +0200
@@ -1,3 +1,13 @@
+2010-05-28  Marcus Crestani  <crestani@informatik.uni-tuebingen.de>
+
+	* mc-alloc.c: 
+	* mc-alloc.c (visit_all_used_page_headers): 
+	* mc-alloc.c (install_page_in_used_list): 
+	* mc-alloc.c (mc_alloc_1): 
+	* mc-alloc.c (init_mc_allocator): 
+	* mc-alloc.c (Fmc_alloc_memory_usage): Allocate lrecord arrays in
+	own size class.
+
 2010-05-24  Mike Sperber  <mike@xemacs.org>
 
 	* lread.c (read1): Accept #B<binary>, #O<octal>, and #X<hex>, just
--- a/src/mc-alloc.c	Fri May 28 13:52:16 2010 +0100
+++ b/src/mc-alloc.c	Sat May 29 07:10:49 2010 +0200
@@ -297,6 +297,9 @@
      to guarantee fast allocation on partially filled pages. */
   page_list_header     *used_heap_pages;
 
+  /* Holds all allocated pages that contain array elements. */
+  page_list_header     array_heap_pages;
+
   /* Holds all free pages in the heap. N multiples of PAGE_SIZE are
      kept on the Nth free list. Contiguos pages are coalesced. */
   page_list_header     free_heap_pages[N_FREE_PAGE_LISTS];
@@ -324,6 +327,9 @@
 #define USED_HEAP_PAGES(i) \
   ((page_list_header*) &mc_allocator_globals.used_heap_pages[i])
 
+#define ARRAY_HEAP_PAGES \
+  ((page_list_header*) &mc_allocator_globals.array_heap_pages)
+
 #define FREE_HEAP_PAGES(i) \
   ((page_list_header*) &mc_allocator_globals.free_heap_pages[i])
 
@@ -437,6 +443,19 @@
           }
         number_of_pages_processed += f (ph);
       }
+
+  if (PLH_FIRST (ARRAY_HEAP_PAGES))
+    {
+      page_header *ph = PLH_FIRST (ARRAY_HEAP_PAGES);
+      while (PH_NEXT (ph))
+	{
+	  page_header *next = PH_NEXT (ph); /* in case f removes the page */
+	  number_of_pages_processed += f (ph);
+	  ph = next;
+	}
+      number_of_pages_processed += f (ph);
+    }
+  
   return number_of_pages_processed;
 }
 
@@ -1172,7 +1191,7 @@
 /*--- used heap functions ----------------------------------------------*/
 /* Installs initial free list. */
 static void
-install_cell_free_list (page_header *ph, EMACS_INT elemcount)
+install_cell_free_list (page_header *ph)
 {
   Rawbyte *p;
   EMACS_INT i;
@@ -1185,7 +1204,7 @@
       assert (!LRECORD_FREE_P (p));
       MARK_LRECORD_AS_FREE (p);
 #endif
-      if (elemcount == 1)
+      if (!PH_ARRAY_BIT (ph))
 	NEXT_FREE (p) = FREE_LIST (p + cell_size);
       set_lookup_table (p, ph);
       p += cell_size;
@@ -1227,7 +1246,10 @@
   else
     PH_CELL_SIZE (ph) = size;
   if (elemcount == 1)
-    PH_CELLS_ON_PAGE (ph) = (PAGE_SIZE * PH_N_PAGES (ph)) / PH_CELL_SIZE (ph);
+    {
+      PH_CELLS_ON_PAGE (ph) = (PAGE_SIZE * PH_N_PAGES (ph)) / PH_CELL_SIZE (ph);
+      PH_ARRAY_BIT (ph) = 0;
+    }
   else
     {
       PH_CELLS_ON_PAGE (ph) = elemcount;
@@ -1240,7 +1262,7 @@
   /* install mark bits and initialize cell free list */
   install_mark_bits (ph);
 
-  install_cell_free_list (ph, elemcount);
+  install_cell_free_list (ph);
 
 #ifdef MEMORY_USAGE_STATS
   PLH_TOTAL_CELLS (plh) += PH_CELLS_ON_PAGE (ph);
@@ -1379,13 +1401,21 @@
   page_header *ph = 0;
   void *result = 0;
 
-  plh = USED_HEAP_PAGES (get_used_list_index (size));
-
   if (size == 0)
     return 0;
-  if ((elemcount == 1) && (size < (size_t) PAGE_SIZE_DIV_2))
-    /* first check any free cells */
-    ph = allocate_cell (plh);
+
+  if (elemcount == 1) 
+    {
+      plh = USED_HEAP_PAGES (get_used_list_index (size));
+      if (size < (size_t) USED_LIST_UPPER_THRESHOLD)
+	/* first check any free cells */
+	ph = allocate_cell (plh);
+    } 
+  else 
+    {
+      plh = ARRAY_HEAP_PAGES;
+    }
+
   if (!ph)
     /* allocate a new page */
     ph = allocate_new_page (plh, size, elemcount);
@@ -1670,6 +1700,22 @@
 #endif
     }
 
+  {
+    page_list_header *plh = ARRAY_HEAP_PAGES;
+    PLH_LIST_TYPE (plh) = USED_LIST;
+    PLH_SIZE (plh) = 0;
+    PLH_FIRST (plh) = 0;
+    PLH_LAST (plh) = 0;
+    PLH_MARK_BIT_FREE_LIST (plh) = 0;
+#ifdef MEMORY_USAGE_STATS
+    PLH_PAGE_COUNT (plh) = 0;
+    PLH_USED_CELLS (plh) = 0;
+    PLH_USED_SPACE (plh) = 0;
+    PLH_TOTAL_CELLS (plh) = 0;
+    PLH_TOTAL_SPACE (plh) = 0;
+#endif
+  }
+
   for (i = 0; i < N_FREE_PAGE_LISTS; i++)
     {
       page_list_header *plh = FREE_HEAP_PAGES (i);
@@ -1735,6 +1781,15 @@
 		      make_int (PLH_TOTAL_SPACE (USED_HEAP_PAGES(i)))),
 	       used_plhs);
 
+  used_plhs =
+    acons (make_int (0),
+	   list5 (make_int (PLH_PAGE_COUNT(ARRAY_HEAP_PAGES)),
+		  make_int (PLH_USED_CELLS (ARRAY_HEAP_PAGES)),
+		  make_int (PLH_USED_SPACE (ARRAY_HEAP_PAGES)),
+		  make_int (PLH_TOTAL_CELLS (ARRAY_HEAP_PAGES)),
+		  make_int (PLH_TOTAL_SPACE (ARRAY_HEAP_PAGES))),
+	   used_plhs);
+  
   for (i = 0; i < N_HEAP_SECTIONS; i++) {
     used_size += HEAP_SECTION(i).n_pages * PAGE_SIZE;
     real_size +=