Mercurial > hg > xemacs-beta
comparison src/window.c @ 5170:5ddbab03b0e6
various fixes to memory-usage stats
-------------------- ChangeLog entries follow: --------------------
lisp/ChangeLog addition:
2010-03-25 Ben Wing <ben@xemacs.org>
* diagnose.el (show-memory-usage):
* diagnose.el (show-object-memory-usage-stats):
Further changes to correspond with changes in the C code;
add an additional column in show-object-memory-usage-stats showing
the ancillary Lisp overhead used with each type; shrink columns for
windows in show-memory-usage to get it to fit in 79 chars.
src/ChangeLog addition:
2010-03-25 Ben Wing <ben@xemacs.org>
* alloc.c:
* alloc.c (struct):
* alloc.c (finish_object_memory_usage_stats):
* alloc.c (object_memory_usage_stats):
* alloc.c (Fobject_memory_usage):
* alloc.c (lisp_object_memory_usage_full):
* alloc.c (compute_memusage_stats_length):
* lrecord.h:
* lrecord.h (struct lrecord_implementation):
Add fields to the `lrecord_implementation' structure to list an
offset into the array of extra statistics in a
`struct generic_usage_stats' and a length, listing the first slice
of ancillary Lisp-object memory. Compute automatically in
compute_memusage_stats_length(). Use to add an entry
`FOO-lisp-ancillary-storage' for object type FOO.
Don't crash when an int or char is given to object-memory-usage,
signal an error instead.
Add functions lisp_object_memory_usage_full() and
lisp_object_memory_usage() to compute the total memory usage of an
object (sum of object, non-Lisp attached, and Lisp ancillary
memory).
* array.c:
* array.c (gap_array_memory_usage):
* array.h:
Add function to return memory usage of a gap array.
* buffer.c (struct buffer_stats):
* buffer.c (compute_buffer_usage):
* buffer.c (vars_of_buffer):
* extents.c (compute_buffer_extent_usage):
* marker.c:
* marker.c (compute_buffer_marker_usage):
* extents.h:
* lisp.h:
Remove `struct usage_stats' arg from compute_buffer_marker_usage()
and compute_buffer_extent_usage() -- these are ancillary Lisp
objects and don't get accumulated into `struct usage_stats';
change the value of `memusage_stats_list' so that `markers' and
`extents' memory is in Lisp-ancillary, where it belongs.
In compute_buffer_marker_usage(), use lisp_object_memory_usage()
rather than lisp_object_storage_size().
* casetab.c:
* casetab.c (case_table_memory_usage):
* casetab.c (vars_of_casetab):
* emacs.c (main_1):
Add memory usage stats for case tables.
* lisp.h:
Add comment explaining the `struct generic_usage_stats' more,
as well as the new fields in lrecord_implementation.
* console-impl.h:
* console-impl.h (struct console_methods):
* scrollbar-gtk.c:
* scrollbar-gtk.c (gtk_compute_scrollbar_instance_usage):
* scrollbar-msw.c:
* scrollbar-msw.c (mswindows_compute_scrollbar_instance_usage):
* scrollbar-x.c:
* scrollbar-x.c (x_compute_scrollbar_instance_usage):
* scrollbar.c:
* scrollbar.c (struct scrollbar_instance_stats):
* scrollbar.c (compute_all_scrollbar_instance_usage):
* scrollbar.c (scrollbar_instance_memory_usage):
* scrollbar.c (scrollbar_objects_create):
* scrollbar.c (vars_of_scrollbar):
* scrollbar.h:
* symsinit.h:
* window.c:
* window.c (find_window_mirror_maybe):
* window.c (struct window_mirror_stats):
* window.c (compute_window_mirror_usage):
* window.c (window_mirror_memory_usage):
* window.c (compute_window_usage):
* window.c (window_objects_create):
* window.c (syms_of_window):
* window.c (vars_of_window):
Redo memory-usage associated with windows, window mirrors, and
scrollbar instances. Should fix crash in find_window_mirror,
among other things. Properly assign memo ry to object memory,
non-Lisp extra memory, and Lisp ancillary memory. For example,
redisplay structures are non-Lisp memory hanging off a window
mirror, not a window; make it an ancillary Lisp-object field.
Window mirrors and scrollbar instances have their own statistics,
among other things.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Thu, 25 Mar 2010 06:07:25 -0500 |
parents | 1fae11d56ad2 |
children | 8cd17b2131a1 |
comparison
equal
deleted
inserted
replaced
5169:6c6d78781d59 | 5170:5ddbab03b0e6 |
---|---|
53 | 53 |
54 Lisp_Object Qwindowp, Qwindow_live_p; | 54 Lisp_Object Qwindowp, Qwindow_live_p; |
55 Lisp_Object Qdisplay_buffer; | 55 Lisp_Object Qdisplay_buffer; |
56 | 56 |
57 #ifdef MEMORY_USAGE_STATS | 57 #ifdef MEMORY_USAGE_STATS |
58 Lisp_Object Qface_cache, Qglyph_cache, Qline_start_cache, Qother_redisplay; | 58 Lisp_Object Qface_cache, Qglyph_cache, Qline_start_cache, Qredisplay_structs; |
59 #ifdef HAVE_SCROLLBARS | 59 #ifdef HAVE_SCROLLBARS |
60 Lisp_Object Qscrollbar_instances; | 60 Lisp_Object Qscrollbar_instances; |
61 #endif | 61 #endif |
62 #endif | 62 #endif |
63 | 63 |
704 find_window_mirror (struct window *w) | 704 find_window_mirror (struct window *w) |
705 { | 705 { |
706 struct frame *f = XFRAME (w->frame); | 706 struct frame *f = XFRAME (w->frame); |
707 if (f->mirror_dirty) | 707 if (f->mirror_dirty) |
708 update_frame_window_mirror (f); | 708 update_frame_window_mirror (f); |
709 return find_window_mirror_internal (f->root_window, | |
710 XWINDOW_MIRROR (f->root_mirror), w); | |
711 } | |
712 | |
713 /* Given a real window, return its mirror structure, if it exists. | |
714 Don't do any updating. */ | |
715 static struct window_mirror * | |
716 find_window_mirror_maybe (struct window *w) | |
717 { | |
718 struct frame *f = XFRAME (w->frame); | |
719 if (!WINDOW_MIRRORP (f->root_mirror)) | |
720 return 0; | |
709 return find_window_mirror_internal (f->root_window, | 721 return find_window_mirror_internal (f->root_window, |
710 XWINDOW_MIRROR (f->root_mirror), w); | 722 XWINDOW_MIRROR (f->root_mirror), w); |
711 } | 723 } |
712 | 724 |
713 /***************************************************************************** | 725 /***************************************************************************** |
5154 MARK_WINDOWS_CHANGED (w); | 5166 MARK_WINDOWS_CHANGED (w); |
5155 } | 5167 } |
5156 | 5168 |
5157 #ifdef MEMORY_USAGE_STATS | 5169 #ifdef MEMORY_USAGE_STATS |
5158 | 5170 |
5171 struct window_mirror_stats | |
5172 { | |
5173 struct usage_stats u; | |
5174 /* Ancilliary non-lisp */ | |
5175 Bytecount redisplay_structs; | |
5176 #ifdef HAVE_SCROLLBARS | |
5177 /* Ancilliary Lisp */ | |
5178 Bytecount scrollbar; | |
5179 #endif | |
5180 }; | |
5181 | |
5159 struct window_stats | 5182 struct window_stats |
5160 { | 5183 { |
5161 struct usage_stats u; | 5184 struct usage_stats u; |
5185 /* Ancillary non-Lisp */ | |
5186 Bytecount line_start; | |
5187 /* The next two: ancillary non-Lisp under old-GC, ancillary Lisp under | |
5188 NEW_GC */ | |
5162 Bytecount face; | 5189 Bytecount face; |
5163 Bytecount glyph; | 5190 Bytecount glyph; |
5164 Bytecount line_start; | 5191 /* The next two are copied out of the window mirror, which is an ancillary |
5165 Bytecount other_redisplay; | 5192 Lisp structure; the first is non-Lisp, the second Lisp, but from our |
5193 perspective, they are both counted as Lisp */ | |
5194 Bytecount redisplay_structs; | |
5166 #ifdef HAVE_SCROLLBARS | 5195 #ifdef HAVE_SCROLLBARS |
5167 Bytecount scrollbar; | 5196 Bytecount scrollbar; |
5168 #endif | 5197 #endif |
5198 /* Remaining memory associated with window mirror (ancillary Lisp) */ | |
5199 Bytecount window_mirror; | |
5169 }; | 5200 }; |
5170 | 5201 |
5171 static void | 5202 static void |
5172 compute_window_mirror_usage (struct window_mirror *mir, | 5203 compute_window_mirror_usage (struct window_mirror *mir, |
5173 struct window_stats *stats, | 5204 struct window_mirror_stats *stats) |
5174 struct usage_stats *ustats) | 5205 { |
5175 { | 5206 stats->redisplay_structs = |
5176 if (!mir) | 5207 compute_display_line_dynarr_usage (mir->current_display_lines, &stats->u) |
5177 return; | 5208 + |
5209 compute_display_line_dynarr_usage (mir->desired_display_lines, &stats->u); | |
5178 #ifdef HAVE_SCROLLBARS | 5210 #ifdef HAVE_SCROLLBARS |
5179 { | 5211 stats->scrollbar = |
5180 struct device *d = XDEVICE (FRAME_DEVICE (mir->frame)); | 5212 compute_all_scrollbar_instance_usage (mir->scrollbar_vertical_instance) + |
5181 | 5213 compute_all_scrollbar_instance_usage (mir->scrollbar_horizontal_instance); |
5182 stats->scrollbar += | |
5183 compute_scrollbar_instance_usage (d, mir->scrollbar_vertical_instance, | |
5184 ustats); | |
5185 stats->scrollbar += | |
5186 compute_scrollbar_instance_usage (d, mir->scrollbar_horizontal_instance, | |
5187 ustats); | |
5188 } | |
5189 #endif /* HAVE_SCROLLBARS */ | 5214 #endif /* HAVE_SCROLLBARS */ |
5190 stats->other_redisplay += | 5215 } |
5191 compute_display_line_dynarr_usage (mir->current_display_lines, ustats); | 5216 |
5192 stats->other_redisplay += | 5217 |
5193 compute_display_line_dynarr_usage (mir->desired_display_lines, ustats); | 5218 static void |
5219 window_mirror_memory_usage (Lisp_Object window_mirror, | |
5220 struct generic_usage_stats *gustats) | |
5221 { | |
5222 struct window_mirror_stats *stats = (struct window_mirror_stats *) gustats; | |
5223 | |
5224 compute_window_mirror_usage (XWINDOW_MIRROR (window_mirror), stats); | |
5194 } | 5225 } |
5195 | 5226 |
5196 static void | 5227 static void |
5197 compute_window_usage (struct window *w, struct window_stats *stats, | 5228 compute_window_usage (struct window *w, struct window_stats *stats, |
5198 struct usage_stats *ustats) | 5229 struct usage_stats *ustats) |
5199 { | 5230 { |
5200 stats->face += compute_face_cachel_usage (w->face_cachels, ustats); | 5231 stats->line_start = |
5201 stats->glyph += compute_glyph_cachel_usage (w->glyph_cachels, ustats); | |
5202 stats->line_start += | |
5203 compute_line_start_cache_dynarr_usage (w->line_start_cache, ustats); | 5232 compute_line_start_cache_dynarr_usage (w->line_start_cache, ustats); |
5204 compute_window_mirror_usage (find_window_mirror (w), stats, ustats); | 5233 stats->face = compute_face_cachel_usage (w->face_cachels, |
5234 IF_OLD_GC (ustats)); | |
5235 stats->glyph = compute_glyph_cachel_usage (w->glyph_cachels, | |
5236 IF_OLD_GC (ustats)); | |
5237 { | |
5238 struct window_mirror *wm; | |
5239 | |
5240 wm = find_window_mirror_maybe (w); | |
5241 if (wm) | |
5242 { | |
5243 struct generic_usage_stats gustats; | |
5244 struct window_mirror_stats *wmstats; | |
5245 Bytecount total; | |
5246 total = lisp_object_memory_usage_full (wrap_window_mirror (wm), | |
5247 NULL, NULL, NULL, &gustats); | |
5248 wmstats = (struct window_mirror_stats *) &gustats; | |
5249 stats->redisplay_structs = wmstats->redisplay_structs; | |
5250 total -= stats->redisplay_structs; | |
5251 #ifdef HAVE_SCROLLBARS | |
5252 stats->scrollbar = wmstats->scrollbar; | |
5253 total -= stats->scrollbar; | |
5254 #endif | |
5255 stats->window_mirror = total; | |
5256 } | |
5257 } | |
5205 } | 5258 } |
5206 | 5259 |
5207 static void | 5260 static void |
5208 window_memory_usage (Lisp_Object window, struct generic_usage_stats *gustats) | 5261 window_memory_usage (Lisp_Object window, struct generic_usage_stats *gustats) |
5209 { | 5262 { |
5394 void | 5447 void |
5395 window_objects_create (void) | 5448 window_objects_create (void) |
5396 { | 5449 { |
5397 #ifdef MEMORY_USAGE_STATS | 5450 #ifdef MEMORY_USAGE_STATS |
5398 OBJECT_HAS_METHOD (window, memory_usage); | 5451 OBJECT_HAS_METHOD (window, memory_usage); |
5452 OBJECT_HAS_METHOD (window_mirror, memory_usage); | |
5399 #endif | 5453 #endif |
5400 } | 5454 } |
5401 | 5455 |
5402 void | 5456 void |
5403 syms_of_window (void) | 5457 syms_of_window (void) |
5420 DEFSYMBOL (Qglyph_cache); | 5474 DEFSYMBOL (Qglyph_cache); |
5421 DEFSYMBOL (Qline_start_cache); | 5475 DEFSYMBOL (Qline_start_cache); |
5422 #ifdef HAVE_SCROLLBARS | 5476 #ifdef HAVE_SCROLLBARS |
5423 DEFSYMBOL (Qscrollbar_instances); | 5477 DEFSYMBOL (Qscrollbar_instances); |
5424 #endif | 5478 #endif |
5425 DEFSYMBOL (Qother_redisplay); | 5479 DEFSYMBOL (Qredisplay_structs); |
5426 #endif | 5480 #endif |
5427 | 5481 |
5428 DEFSYMBOL (Qtruncate_partial_width_windows); | 5482 DEFSYMBOL (Qtruncate_partial_width_windows); |
5429 DEFSYMBOL (Qcurrent_window_configuration); | 5483 DEFSYMBOL (Qcurrent_window_configuration); |
5430 DEFSYMBOL (Qset_window_configuration); | 5484 DEFSYMBOL (Qset_window_configuration); |
5514 | 5568 |
5515 void | 5569 void |
5516 vars_of_window (void) | 5570 vars_of_window (void) |
5517 { | 5571 { |
5518 #ifdef MEMORY_USAGE_STATS | 5572 #ifdef MEMORY_USAGE_STATS |
5519 OBJECT_HAS_PROPERTY | 5573 Lisp_Object l; |
5520 (window, memusage_stats_list, | 5574 |
5521 listu (Qface_cache, Qglyph_cache, | 5575 l = listu (Qline_start_cache, |
5522 Qline_start_cache, Qother_redisplay, | 5576 #ifdef NEW_GC |
5577 Qt, | |
5578 #endif | |
5579 Qface_cache, Qglyph_cache, | |
5580 #ifndef NEW_GC | |
5581 Qt, | |
5582 #endif | |
5583 Qredisplay_structs, | |
5523 #ifdef HAVE_SCROLLBARS | 5584 #ifdef HAVE_SCROLLBARS |
5524 Qscrollbar_instances, | 5585 Qscrollbar_instances, |
5525 #endif | 5586 #endif |
5526 Qunbound)); | 5587 intern ("window-mirror"), |
5588 Qunbound); | |
5589 | |
5590 OBJECT_HAS_PROPERTY (window, memusage_stats_list, l); | |
5591 | |
5592 l = listu (Qredisplay_structs, | |
5593 #ifdef HAVE_SCROLLBARS | |
5594 Qt, Qscrollbar_instances, | |
5595 #endif | |
5596 Qunbound); | |
5597 OBJECT_HAS_PROPERTY (window_mirror, memusage_stats_list, l); | |
5527 #endif /* MEMORY_USAGE_STATS */ | 5598 #endif /* MEMORY_USAGE_STATS */ |
5528 | 5599 |
5529 DEFVAR_BOOL ("scroll-on-clipped-lines", &scroll_on_clipped_lines /* | 5600 DEFVAR_BOOL ("scroll-on-clipped-lines", &scroll_on_clipped_lines /* |
5530 *Non-nil means to scroll if point lands on a line which is clipped. | 5601 *Non-nil means to scroll if point lands on a line which is clipped. |
5531 */ ); | 5602 */ ); |