diff src/dumper.c @ 2775:05d62157e048

[xemacs-hg @ 2005-05-15 16:37:52 by crestani] New allocator improvements lisp/ChangeLog addition: 2005-05-15 Marcus Crestani <crestani@xemacs.org> * diagnose.el: Lrecord and string data statistics. * diagnose.el (show-memory-usage): Add output for additional lrecord statistics (currently only string data). * diagnose.el (show-lrecord-stats): New. Print detailed lrecord statistics. src/ChangeLog addition: 2005-05-15 Marcus Crestani <crestani@xemacs.org> * alloc.c: Add string data statistics. * alloc.c (dec_lrecord_stats): Use size of lrecord for statistics and cons counter bookkeeping. * alloc.c (finalize_string): Add string data statistics. * alloc.c (make_uninit_string): Add string data statistics. * alloc.c (make_string_nocopy): Add string data statistics. * alloc.c (kkcc_marking): Move break out of #ifdef. * alloc.c (Flrecord_stats): New. Collect lrecord statistics. * alloc.c (Fgarbage_collect): Use Flrecord_stats. * alloc.c (syms_of_alloc): Add Flrecord_stats. * dumper.c: Fix hash table. * dumper.c (pdump_make_hash): Fix hash table. * dumper.c (pdump_get_mc_addr): Fix hash table. * dumper.c (pdump_put_mc_addr): Fix hash table. * dumper.c (pdump_reloc_one_mc): Fix indentation. * dumper.c (pdump_load_finish): Add lrecord statistics bookkeeping. * lrecord.h: Add string data statistics. * mc-alloc.c (remove_cell): Lrecord statistics, fix indentation. * mule-charset.c: Marking through *_unicode_description not needed. * symbols.c (init_symbols_once_early): Bump lrecord statistics. * window.c: Marking through line_start_cache not needed. * xemacs.def.in.in: Fix typo.
author crestani
date Sun, 15 May 2005 16:38:14 +0000
parents c474585a3460
children f39be22beaf1
line wrap: on
line diff
--- a/src/dumper.c	Sat May 14 21:50:55 2005 +0000
+++ b/src/dumper.c	Sun May 15 16:38:14 2005 +0000
@@ -434,23 +434,29 @@
 static void *pdump_buf;
 static FILE *pdump_out;
 
-#if defined (MC_ALLOC)
-/* With mc_alloc, way more entries are added to the hash tables:
-   increase hash table size to avoid collisions. */
-#define PDUMP_HASHSIZE 1000001
+#ifdef MC_ALLOC
+/* PDUMP_HASHSIZE is a large prime. */
+#define PDUMP_HASHSIZE        1000003
+/* Nothing special about PDUMP_HASH_MULTIPLIER: arbitrary odd integer
+   smaller than PDUMP_HASHSIZE. */
+#define PDUMP_HASH_MULTIPLIER   12347
+/* Nothing special about PDUMP_HASH_STEP: arbitrary integer for linear
+   probing. */
+#define PDUMP_HASH_STEP        574853
 #else /* not MC_ALLOC */
 #define PDUMP_HASHSIZE 200001
 #endif /* not MC_ALLOC */
 
 static pdump_block_list_elt **pdump_hash;
 
+#ifndef MC_ALLOC
 /* Since most pointers are eight bytes aligned, the >>3 allows for a better hash */
+#endif /* not MC_ALLOC */
 static int
 pdump_make_hash (const void *obj)
 {
-#if defined (MC_ALLOC)
-  /* Use >>2 for a better hash to avoid collisions. */
-  return ((unsigned long)(obj)>>2) % PDUMP_HASHSIZE;
+#ifdef MC_ALLOC
+  return ((unsigned long)(obj) * PDUMP_HASH_MULTIPLIER) % PDUMP_HASHSIZE;
 #else /* not MC_ALLOC */
   return ((unsigned long)(obj)>>3) % PDUMP_HASHSIZE;
 #endif /* not MC_ALLOC */
@@ -542,9 +548,9 @@
       if (mc_addr->obj == obj)
 	return mc_addr->addr;
 
-      pos++;
-      if (pos == PDUMP_HASHSIZE)
-	pos = 0;
+      pos += PDUMP_HASH_STEP;
+      if (pos >= PDUMP_HASHSIZE)
+	pos -= PDUMP_HASHSIZE;
     }
 
   /* If this code is reached, an heap address occurred which has not
@@ -573,9 +579,9 @@
       if (mc_addr->obj == obj)
 	return;
 
-      pos++;
-      if (pos == PDUMP_HASHSIZE)
-	pos = 0;
+      pos += PDUMP_HASH_STEP;
+      if (pos >= PDUMP_HASHSIZE)
+	pos -= PDUMP_HASHSIZE;
     }
 
   pdump_mc_hash[pos].obj = obj;
@@ -1263,7 +1269,7 @@
 		if (POINTER_TYPE_P (XTYPE (*pobj))
 		    && ! EQ (*pobj, Qnull_pointer))
 		  *pobj = wrap_pointer_1 ((char *) pdump_get_mc_addr 
-					   (XPNTR (*pobj)));
+					  (XPNTR (*pobj)));
 	      }
 	    break;
 	  }
@@ -2155,11 +2161,21 @@
 	      if (i == 0)
 		{
 		  Bytecount real_size = size * elt_count;
-#ifdef MC_ALLOC
 		  if (count == 2)
-		    mc_addr = (Rawbyte *) mc_alloc (real_size);
+		    {
+		      mc_addr = (Rawbyte *) mc_alloc (real_size);
+#ifdef MC_ALLOC_TYPE_STATS
+		      inc_lrecord_stats (real_size, 
+					 (const struct lrecord_header *) 
+					 ((char *) rdata + delta));
+		      if (((const struct lrecord_header *) 
+			   ((char *) rdata + delta))->type 
+			  == lrecord_type_string)
+			inc_lrecord_string_data_stats 
+			  (((Lisp_String *) ((char *) rdata + delta))->size_);
+#endif /* not MC_ALLOC_TYPE_STATS */
+		    }
 		  else
-#endif /* not MC_ALLOC */
 		    mc_addr = (Rawbyte *) xmalloc_and_zero (real_size);
 		}
 	      else