Mercurial > hg > xemacs-beta
comparison src/alloc.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 | 6fa9919a9a0b |
children | adda8fccb13d |
comparison
equal
deleted
inserted
replaced
2774:d72eefd1305a | 2775:05d62157e048 |
---|---|
517 int bytes_in_use; | 517 int bytes_in_use; |
518 int bytes_in_use_including_overhead; | 518 int bytes_in_use_including_overhead; |
519 } lrecord_stats [countof (lrecord_implementations_table) | 519 } lrecord_stats [countof (lrecord_implementations_table) |
520 + MODULE_DEFINABLE_TYPE_COUNT]; | 520 + MODULE_DEFINABLE_TYPE_COUNT]; |
521 | 521 |
522 int lrecord_string_data_instances_in_use; | |
523 int lrecord_string_data_bytes_in_use; | |
524 int lrecord_string_data_bytes_in_use_including_overhead; | |
525 | |
522 void | 526 void |
523 init_lrecord_stats () | 527 init_lrecord_stats () |
524 { | 528 { |
525 xzero (lrecord_stats); | 529 xzero (lrecord_stats); |
530 lrecord_string_data_instances_in_use = 0; | |
531 lrecord_string_data_bytes_in_use = 0; | |
532 lrecord_string_data_bytes_in_use_including_overhead = 0; | |
533 } | |
534 | |
535 void | |
536 inc_lrecord_string_data_stats (Bytecount size) | |
537 { | |
538 lrecord_string_data_instances_in_use++; | |
539 lrecord_string_data_bytes_in_use += size; | |
540 lrecord_string_data_bytes_in_use_including_overhead += size; | |
541 } | |
542 | |
543 void | |
544 dec_lrecord_string_data_stats (Bytecount size) | |
545 { | |
546 lrecord_string_data_instances_in_use--; | |
547 lrecord_string_data_bytes_in_use -= size; | |
548 lrecord_string_data_bytes_in_use_including_overhead -= size; | |
526 } | 549 } |
527 | 550 |
528 void | 551 void |
529 inc_lrecord_stats (Bytecount size, const struct lrecord_header *h) | 552 inc_lrecord_stats (Bytecount size, const struct lrecord_header *h) |
530 { | 553 { |
545 void | 568 void |
546 dec_lrecord_stats (Bytecount size_including_overhead, | 569 dec_lrecord_stats (Bytecount size_including_overhead, |
547 const struct lrecord_header *h) | 570 const struct lrecord_header *h) |
548 { | 571 { |
549 int type_index = h->type; | 572 int type_index = h->type; |
573 int size = detagged_lisp_object_size (h); | |
550 | 574 |
551 lrecord_stats[type_index].instances_in_use--; | 575 lrecord_stats[type_index].instances_in_use--; |
552 lrecord_stats[type_index].bytes_in_use -= detagged_lisp_object_size (h); | 576 lrecord_stats[type_index].bytes_in_use -= size; |
553 lrecord_stats[type_index].bytes_in_use_including_overhead | 577 lrecord_stats[type_index].bytes_in_use_including_overhead |
554 -= size_including_overhead; | 578 -= size_including_overhead; |
555 | 579 |
556 DECREMENT_CONS_COUNTER (lrecord_stats[type_index].bytes_in_use); | 580 DECREMENT_CONS_COUNTER (size); |
557 } | 581 } |
558 #endif /* not MC_ALLOC_TYPE_STATS */ | 582 #endif /* not MC_ALLOC_TYPE_STATS */ |
559 | 583 |
560 #ifndef MC_ALLOC | 584 #ifndef MC_ALLOC |
561 /* lcrecords are chained together through their "next" field. | 585 /* lcrecords are chained together through their "next" field. |
2466 { | 2490 { |
2467 if (!for_disksave) | 2491 if (!for_disksave) |
2468 { | 2492 { |
2469 Lisp_String *s = (Lisp_String *) header; | 2493 Lisp_String *s = (Lisp_String *) header; |
2470 Bytecount size = s->size_; | 2494 Bytecount size = s->size_; |
2495 #ifdef MC_ALLOC_TYPE_STATS | |
2496 dec_lrecord_string_data_stats (size); | |
2497 #endif /* MC_ALLOC_TYPE_STATS */ | |
2471 if (BIG_STRING_SIZE_P (size)) | 2498 if (BIG_STRING_SIZE_P (size)) |
2472 xfree (s->data_, Ibyte *); | 2499 xfree (s->data_, Ibyte *); |
2473 } | 2500 } |
2474 } | 2501 } |
2475 | 2502 |
2585 | 2612 |
2586 assert (length >= 0 && fullsize > 0); | 2613 assert (length >= 0 && fullsize > 0); |
2587 | 2614 |
2588 #ifdef MC_ALLOC | 2615 #ifdef MC_ALLOC |
2589 s = alloc_lrecord_type (Lisp_String, &lrecord_string); | 2616 s = alloc_lrecord_type (Lisp_String, &lrecord_string); |
2617 #ifdef MC_ALLOC_TYPE_STATS | |
2618 inc_lrecord_string_data_stats (length); | |
2619 #endif /* MC_ALLOC_TYPE_STATS */ | |
2590 #else /* not MC_ALLOC */ | 2620 #else /* not MC_ALLOC */ |
2591 /* Allocate the string header */ | 2621 /* Allocate the string header */ |
2592 ALLOCATE_FIXED_TYPE (string, Lisp_String, s); | 2622 ALLOCATE_FIXED_TYPE (string, Lisp_String, s); |
2593 xzero (*s); | 2623 xzero (*s); |
2594 set_lheader_implementation (&s->u.lheader, &lrecord_string); | 2624 set_lheader_implementation (&s->u.lheader, &lrecord_string); |
2968 bytecount_to_charcount (contents, length); /* Just for the assertions */ | 2998 bytecount_to_charcount (contents, length); /* Just for the assertions */ |
2969 #endif | 2999 #endif |
2970 | 3000 |
2971 #ifdef MC_ALLOC | 3001 #ifdef MC_ALLOC |
2972 s = alloc_lrecord_type (Lisp_String, &lrecord_string); | 3002 s = alloc_lrecord_type (Lisp_String, &lrecord_string); |
3003 #ifdef MC_ALLOC_TYPE_STATS | |
3004 inc_lrecord_string_data_stats (length); | |
3005 #endif /* MC_ALLOC_TYPE_STATS */ | |
2973 mcpro (wrap_pointer_1 (s)); /* otherwise nocopy_strings get | 3006 mcpro (wrap_pointer_1 (s)); /* otherwise nocopy_strings get |
2974 collected and static data is tried to | 3007 collected and static data is tried to |
2975 be freed. */ | 3008 be freed. */ |
2976 #else /* not MC_ALLOC */ | 3009 #else /* not MC_ALLOC */ |
2977 /* Allocate the string header */ | 3010 /* Allocate the string header */ |
4111 mark_object_maybe_checking_free (*stored_obj, 0, level, pos); | 4144 mark_object_maybe_checking_free (*stored_obj, 0, level, pos); |
4112 #else /* not MC_ALLOC */ | 4145 #else /* not MC_ALLOC */ |
4113 mark_object_maybe_checking_free | 4146 mark_object_maybe_checking_free |
4114 (*stored_obj, (desc1->flags) & XD_FLAG_FREE_LISP_OBJECT, | 4147 (*stored_obj, (desc1->flags) & XD_FLAG_FREE_LISP_OBJECT, |
4115 level, pos); | 4148 level, pos); |
4149 #endif /* not MC_ALLOC */ | |
4116 break; | 4150 break; |
4117 #endif /* not MC_ALLOC */ | |
4118 } | 4151 } |
4119 case XD_LISP_OBJECT_ARRAY: | 4152 case XD_LISP_OBJECT_ARRAY: |
4120 { | 4153 { |
4121 int i; | 4154 int i; |
4122 EMACS_INT count = | 4155 EMACS_INT count = |
5642 /* C doesn't have local functions (or closures, or GC, or readable syntax, | 5675 /* C doesn't have local functions (or closures, or GC, or readable syntax, |
5643 or portable numeric datatypes, or bit-vectors, or characters, or | 5676 or portable numeric datatypes, or bit-vectors, or characters, or |
5644 arrays, or exceptions, or ...) */ | 5677 arrays, or exceptions, or ...) */ |
5645 return cons3 (intern (name), make_int (value), tail); | 5678 return cons3 (intern (name), make_int (value), tail); |
5646 } | 5679 } |
5647 #endif /* MC_ALLOC_TYPE_STATS */ | 5680 |
5648 | 5681 DEFUN("lrecord-stats", Flrecord_stats, 0, 0 ,"", /* |
5649 DEFUN ("garbage-collect", Fgarbage_collect, 0, 0, "", /* | 5682 Return statistics about lrecords in a property list. |
5650 Reclaim storage for Lisp objects no longer needed. | |
5651 Return info on amount of space in use: | |
5652 ((USED-CONSES . STORAGE-CONSES) (USED-SYMS . STORAGE-SYMS) | |
5653 (USED-MARKERS . STORAGE-MARKERS) USED-STRING-CHARS USED-VECTOR-SLOTS | |
5654 PLIST) | |
5655 where `PLIST' is a list of alternating keyword/value pairs providing | |
5656 more detailed information. | |
5657 Garbage collection happens automatically if you cons more than | |
5658 `gc-cons-threshold' bytes of Lisp data since previous garbage collection. | |
5659 */ | 5683 */ |
5660 ()) | 5684 ()) |
5661 { | 5685 { |
5662 #ifdef MC_ALLOC_TYPE_STATS | |
5663 Lisp_Object pl = Qnil; | 5686 Lisp_Object pl = Qnil; |
5664 int i; | 5687 int i; |
5665 #endif /* not MC_ALLOC_TYPE_STATS */ | 5688 |
5666 | |
5667 garbage_collect_1 (); | |
5668 | |
5669 #ifdef MC_ALLOC_TYPE_STATS | |
5670 for (i = 0; i < (countof (lrecord_implementations_table) | 5689 for (i = 0; i < (countof (lrecord_implementations_table) |
5671 + MODULE_DEFINABLE_TYPE_COUNT); i++) | 5690 + MODULE_DEFINABLE_TYPE_COUNT); i++) |
5672 { | 5691 { |
5673 if (lrecord_stats[i].instances_in_use != 0) | 5692 if (lrecord_stats[i].instances_in_use != 0) |
5674 { | 5693 { |
5696 else | 5715 else |
5697 sprintf (buf, "%ss-used", name); | 5716 sprintf (buf, "%ss-used", name); |
5698 pl = gc_plist_hack (buf, lrecord_stats[i].instances_in_use, pl); | 5717 pl = gc_plist_hack (buf, lrecord_stats[i].instances_in_use, pl); |
5699 } | 5718 } |
5700 } | 5719 } |
5701 | 5720 pl = gc_plist_hack ("string-data-storage-including-overhead", |
5721 lrecord_string_data_bytes_in_use_including_overhead, pl); | |
5722 pl = gc_plist_hack ("string-data-storage-additional", | |
5723 lrecord_string_data_bytes_in_use, pl); | |
5724 pl = gc_plist_hack ("string-data-used", | |
5725 lrecord_string_data_instances_in_use, pl); | |
5726 | |
5727 return pl; | |
5728 } | |
5729 #endif /* not MC_ALLOC_TYPE_STATS */ | |
5730 | |
5731 DEFUN ("garbage-collect", Fgarbage_collect, 0, 0, "", /* | |
5732 Reclaim storage for Lisp objects no longer needed. | |
5733 Return info on amount of space in use: | |
5734 ((USED-CONSES . STORAGE-CONSES) (USED-SYMS . STORAGE-SYMS) | |
5735 (USED-MARKERS . STORAGE-MARKERS) USED-STRING-CHARS USED-VECTOR-SLOTS | |
5736 PLIST) | |
5737 where `PLIST' is a list of alternating keyword/value pairs providing | |
5738 more detailed information. | |
5739 Garbage collection happens automatically if you cons more than | |
5740 `gc-cons-threshold' bytes of Lisp data since previous garbage collection. | |
5741 */ | |
5742 ()) | |
5743 { | |
5744 garbage_collect_1 (); | |
5745 | |
5746 #ifdef MC_ALLOC_TYPE_STATS | |
5702 /* The things we do for backwards-compatibility */ | 5747 /* The things we do for backwards-compatibility */ |
5703 return | 5748 return |
5704 list6 | 5749 list6 |
5705 (Fcons (make_int (lrecord_stats[lrecord_type_cons].instances_in_use), | 5750 (Fcons (make_int (lrecord_stats[lrecord_type_cons].instances_in_use), |
5706 make_int (lrecord_stats[lrecord_type_cons] | 5751 make_int (lrecord_stats[lrecord_type_cons] |
5707 .bytes_in_use_including_overhead)), | 5752 .bytes_in_use_including_overhead)), |
5708 Fcons (make_int (lrecord_stats[lrecord_type_symbol].instances_in_use), | 5753 Fcons (make_int (lrecord_stats[lrecord_type_symbol].instances_in_use), |
5709 make_int (lrecord_stats[lrecord_type_symbol] | 5754 make_int (lrecord_stats[lrecord_type_symbol] |
5710 .bytes_in_use_including_overhead)), | 5755 .bytes_in_use_including_overhead)), |
5711 Fcons (make_int (lrecord_stats[lrecord_type_marker].instances_in_use), | 5756 Fcons (make_int (lrecord_stats[lrecord_type_marker].instances_in_use), |
5712 make_int (lrecord_stats[lrecord_type_marker] | 5757 make_int (lrecord_stats[lrecord_type_marker] |
5713 .bytes_in_use_including_overhead)), | 5758 .bytes_in_use_including_overhead)), |
5714 make_int (lrecord_stats[lrecord_type_string] | 5759 make_int (lrecord_stats[lrecord_type_string] |
5715 .bytes_in_use_including_overhead), | 5760 .bytes_in_use_including_overhead), |
5716 make_int (lrecord_stats[lrecord_type_vector] | 5761 make_int (lrecord_stats[lrecord_type_vector] |
5717 .bytes_in_use_including_overhead), | 5762 .bytes_in_use_including_overhead), |
5718 pl); | 5763 Flrecord_stats ()); |
5719 #else /* not MC_ALLOC_TYPE_STATS */ | 5764 #else /* not MC_ALLOC_TYPE_STATS */ |
5720 return Qnil; | 5765 return Qnil; |
5721 #endif /* not MC_ALLOC_TYPE_STATS */ | 5766 #endif /* not MC_ALLOC_TYPE_STATS */ |
5722 } | 5767 } |
5723 #else /* not MC_ALLOC */ | 5768 #else /* not MC_ALLOC */ |
6300 DEFSUBR (Fmake_string); | 6345 DEFSUBR (Fmake_string); |
6301 DEFSUBR (Fstring); | 6346 DEFSUBR (Fstring); |
6302 DEFSUBR (Fmake_symbol); | 6347 DEFSUBR (Fmake_symbol); |
6303 DEFSUBR (Fmake_marker); | 6348 DEFSUBR (Fmake_marker); |
6304 DEFSUBR (Fpurecopy); | 6349 DEFSUBR (Fpurecopy); |
6350 #ifdef MC_ALLOC_TYPE_STATS | |
6351 DEFSUBR (Flrecord_stats); | |
6352 #endif /* MC_ALLOC_TYPE_STATS */ | |
6305 DEFSUBR (Fgarbage_collect); | 6353 DEFSUBR (Fgarbage_collect); |
6306 #if 0 | 6354 #if 0 |
6307 DEFSUBR (Fmemory_limit); | 6355 DEFSUBR (Fmemory_limit); |
6308 #endif | 6356 #endif |
6309 DEFSUBR (Fmemory_usage); | 6357 DEFSUBR (Fmemory_usage); |