comparison 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
comparison
equal deleted inserted replaced
2774:d72eefd1305a 2775:05d62157e048
432 static Bytecount max_size; 432 static Bytecount max_size;
433 static int pdump_fd; 433 static int pdump_fd;
434 static void *pdump_buf; 434 static void *pdump_buf;
435 static FILE *pdump_out; 435 static FILE *pdump_out;
436 436
437 #if defined (MC_ALLOC) 437 #ifdef MC_ALLOC
438 /* With mc_alloc, way more entries are added to the hash tables: 438 /* PDUMP_HASHSIZE is a large prime. */
439 increase hash table size to avoid collisions. */ 439 #define PDUMP_HASHSIZE 1000003
440 #define PDUMP_HASHSIZE 1000001 440 /* Nothing special about PDUMP_HASH_MULTIPLIER: arbitrary odd integer
441 smaller than PDUMP_HASHSIZE. */
442 #define PDUMP_HASH_MULTIPLIER 12347
443 /* Nothing special about PDUMP_HASH_STEP: arbitrary integer for linear
444 probing. */
445 #define PDUMP_HASH_STEP 574853
441 #else /* not MC_ALLOC */ 446 #else /* not MC_ALLOC */
442 #define PDUMP_HASHSIZE 200001 447 #define PDUMP_HASHSIZE 200001
443 #endif /* not MC_ALLOC */ 448 #endif /* not MC_ALLOC */
444 449
445 static pdump_block_list_elt **pdump_hash; 450 static pdump_block_list_elt **pdump_hash;
446 451
452 #ifndef MC_ALLOC
447 /* Since most pointers are eight bytes aligned, the >>3 allows for a better hash */ 453 /* Since most pointers are eight bytes aligned, the >>3 allows for a better hash */
454 #endif /* not MC_ALLOC */
448 static int 455 static int
449 pdump_make_hash (const void *obj) 456 pdump_make_hash (const void *obj)
450 { 457 {
451 #if defined (MC_ALLOC) 458 #ifdef MC_ALLOC
452 /* Use >>2 for a better hash to avoid collisions. */ 459 return ((unsigned long)(obj) * PDUMP_HASH_MULTIPLIER) % PDUMP_HASHSIZE;
453 return ((unsigned long)(obj)>>2) % PDUMP_HASHSIZE;
454 #else /* not MC_ALLOC */ 460 #else /* not MC_ALLOC */
455 return ((unsigned long)(obj)>>3) % PDUMP_HASHSIZE; 461 return ((unsigned long)(obj)>>3) % PDUMP_HASHSIZE;
456 #endif /* not MC_ALLOC */ 462 #endif /* not MC_ALLOC */
457 } 463 }
458 464
540 while (((mc_addr = &pdump_mc_hash[pos]) != 0) && (mc_addr->obj != 0)) 546 while (((mc_addr = &pdump_mc_hash[pos]) != 0) && (mc_addr->obj != 0))
541 { 547 {
542 if (mc_addr->obj == obj) 548 if (mc_addr->obj == obj)
543 return mc_addr->addr; 549 return mc_addr->addr;
544 550
545 pos++; 551 pos += PDUMP_HASH_STEP;
546 if (pos == PDUMP_HASHSIZE) 552 if (pos >= PDUMP_HASHSIZE)
547 pos = 0; 553 pos -= PDUMP_HASHSIZE;
548 } 554 }
549 555
550 /* If this code is reached, an heap address occurred which has not 556 /* If this code is reached, an heap address occurred which has not
551 been written to the lookup table before. 557 been written to the lookup table before.
552 This is a bug! */ 558 This is a bug! */
571 while (((mc_addr = &pdump_mc_hash[pos]) != 0) && (mc_addr->obj != 0)) 577 while (((mc_addr = &pdump_mc_hash[pos]) != 0) && (mc_addr->obj != 0))
572 { 578 {
573 if (mc_addr->obj == obj) 579 if (mc_addr->obj == obj)
574 return; 580 return;
575 581
576 pos++; 582 pos += PDUMP_HASH_STEP;
577 if (pos == PDUMP_HASHSIZE) 583 if (pos >= PDUMP_HASHSIZE)
578 pos = 0; 584 pos -= PDUMP_HASHSIZE;
579 } 585 }
580 586
581 pdump_mc_hash[pos].obj = obj; 587 pdump_mc_hash[pos].obj = obj;
582 pdump_mc_hash[pos].addr = addr; 588 pdump_mc_hash[pos].addr = addr;
583 } 589 }
1261 Lisp_Object *pobj = (Lisp_Object *) rdata + j; 1267 Lisp_Object *pobj = (Lisp_Object *) rdata + j;
1262 1268
1263 if (POINTER_TYPE_P (XTYPE (*pobj)) 1269 if (POINTER_TYPE_P (XTYPE (*pobj))
1264 && ! EQ (*pobj, Qnull_pointer)) 1270 && ! EQ (*pobj, Qnull_pointer))
1265 *pobj = wrap_pointer_1 ((char *) pdump_get_mc_addr 1271 *pobj = wrap_pointer_1 ((char *) pdump_get_mc_addr
1266 (XPNTR (*pobj))); 1272 (XPNTR (*pobj)));
1267 } 1273 }
1268 break; 1274 break;
1269 } 1275 }
1270 case XD_DOC_STRING: 1276 case XD_DOC_STRING:
1271 { 1277 {
2153 EMACS_INT rdata = PDUMP_READ_ALIGNED (p, EMACS_INT); 2159 EMACS_INT rdata = PDUMP_READ_ALIGNED (p, EMACS_INT);
2154 2160
2155 if (i == 0) 2161 if (i == 0)
2156 { 2162 {
2157 Bytecount real_size = size * elt_count; 2163 Bytecount real_size = size * elt_count;
2158 #ifdef MC_ALLOC
2159 if (count == 2) 2164 if (count == 2)
2160 mc_addr = (Rawbyte *) mc_alloc (real_size); 2165 {
2166 mc_addr = (Rawbyte *) mc_alloc (real_size);
2167 #ifdef MC_ALLOC_TYPE_STATS
2168 inc_lrecord_stats (real_size,
2169 (const struct lrecord_header *)
2170 ((char *) rdata + delta));
2171 if (((const struct lrecord_header *)
2172 ((char *) rdata + delta))->type
2173 == lrecord_type_string)
2174 inc_lrecord_string_data_stats
2175 (((Lisp_String *) ((char *) rdata + delta))->size_);
2176 #endif /* not MC_ALLOC_TYPE_STATS */
2177 }
2161 else 2178 else
2162 #endif /* not MC_ALLOC */
2163 mc_addr = (Rawbyte *) xmalloc_and_zero (real_size); 2179 mc_addr = (Rawbyte *) xmalloc_and_zero (real_size);
2164 } 2180 }
2165 else 2181 else
2166 mc_addr += size; 2182 mc_addr += size;
2167 2183