Mercurial > hg > xemacs-beta
comparison src/elhash.c @ 5158:9e0b43d3095c
more cleanups to object-memory-usage stuff
-------------------- ChangeLog entries follow: --------------------
lisp/ChangeLog addition:
2010-03-19 Ben Wing <ben@xemacs.org>
* diagnose.el (show-object-memory-usage-stats):
Rewrite to take into account non-lisp-storage statistics
returned by garbage-collect-1 and friends.
src/ChangeLog addition:
2010-03-19 Ben Wing <ben@xemacs.org>
* alloc.c:
* alloc.c (struct):
* alloc.c (tick_lrecord_stats):
* alloc.c (gc_sweep_1):
* alloc.c (finish_object_memory_usage_stats):
* alloc.c (object_memory_usage_stats):
* alloc.c (compute_memusage_stats_length):
Call new memory-usage mechanism at sweep time to compute extra
memory utilization for all objects. Add up the values element-by-
element to get an aggregrate set of statistics, where each is the
sum of the values of a single statistic across different objects
of the same type. At end of sweep time, call
finish_object_memory_usage_stats() to add up all the aggreggrate
stats that are related to non-Lisp memory storage to compute
a single value, and add it to the list of values returned by
`garbage-collect' and `object-memory-usage-stats'.
* buffer.c (compute_buffer_text_usage):
Don't crash on buffers without text (killed buffers?) and don't
double-count indirect buffers.
* elhash.c:
* elhash.c (hash_table_objects_create):
* elhash.c (vars_of_elhash):
* symsinit.h:
Add memory-usage method to count the size of `hentries'.
* emacs.c (main_1):
Call new functions in elhash.c, frame.c at init.
* frame.c:
* frame.c (compute_frame_usage):
* frame.c (frame_memory_usage):
* frame.c (frame_objects_create):
* symsinit.h:
Add memory-usage method to count gutter display structures,
subwindow exposures.
* gc.c (gc_finish):
* lisp.h:
Declare finish_object_memory_usage_stats(), call it in gc_finish().
* lrecord.h (struct lrecord_implementation):
* lrecord.h (INIT_MEMORY_USAGE_STATS):
New value in implementation struct to track number of non-Lisp-memory
statistics. Computed in alloc.c.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Fri, 19 Mar 2010 14:47:44 -0500 |
parents | 88bd4f3ef8e4 |
children | 6c6d78781d59 |
comparison
equal
deleted
inserted
replaced
5157:1fae11d56ad2 | 5158:9e0b43d3095c |
---|---|
278 hash_table_hash (Lisp_Object hash_table, int UNUSED (depth)) | 278 hash_table_hash (Lisp_Object hash_table, int UNUSED (depth)) |
279 { | 279 { |
280 return XHASH_TABLE (hash_table)->count; | 280 return XHASH_TABLE (hash_table)->count; |
281 } | 281 } |
282 | 282 |
283 #ifdef MEMORY_USAGE_STATS | |
284 | |
285 struct hash_table_stats | |
286 { | |
287 struct usage_stats u; | |
288 Bytecount hentries; | |
289 }; | |
290 | |
291 static void | |
292 hash_table_memory_usage (Lisp_Object hashtab, | |
293 struct generic_usage_stats *gustats) | |
294 { | |
295 Lisp_Hash_Table *ht = XHASH_TABLE (hashtab); | |
296 struct hash_table_stats *stats = (struct hash_table_stats *) gustats; | |
297 stats->hentries += | |
298 malloced_storage_size (ht->hentries, | |
299 sizeof (htentry) * (ht->size + 1), | |
300 &stats->u); | |
301 } | |
302 | |
303 #endif /* MEMORY_USAGE_STATS */ | |
304 | |
283 | 305 |
284 /* Printing hash tables. | 306 /* Printing hash tables. |
285 | 307 |
286 This is non-trivial, because we use a readable structure-style | 308 This is non-trivial, because we use a readable structure-style |
287 syntax for hash tables. This means that a typical hash table will be | 309 syntax for hash tables. This means that a typical hash table will be |
1801 | 1823 |
1802 | 1824 |
1803 /************************************************************************/ | 1825 /************************************************************************/ |
1804 /* initialization */ | 1826 /* initialization */ |
1805 /************************************************************************/ | 1827 /************************************************************************/ |
1828 | |
1829 void | |
1830 hash_table_objects_create (void) | |
1831 { | |
1832 #ifdef MEMORY_USAGE_STATS | |
1833 OBJECT_HAS_METHOD (hash_table, memory_usage); | |
1834 #endif | |
1835 } | |
1806 | 1836 |
1807 void | 1837 void |
1808 syms_of_elhash (void) | 1838 syms_of_elhash (void) |
1809 { | 1839 { |
1810 DEFSUBR (Fhash_table_p); | 1840 DEFSUBR (Fhash_table_p); |
1852 DEFKEYWORD (Q_weakness); | 1882 DEFKEYWORD (Q_weakness); |
1853 DEFKEYWORD (Q_type); /* obsolete */ | 1883 DEFKEYWORD (Q_type); /* obsolete */ |
1854 } | 1884 } |
1855 | 1885 |
1856 void | 1886 void |
1887 vars_of_elhash (void) | |
1888 { | |
1889 #ifdef MEMORY_USAGE_STATS | |
1890 OBJECT_HAS_PROPERTY | |
1891 (hash_table, memusage_stats_list, list1 (intern ("hash-entries"))); | |
1892 #endif /* MEMORY_USAGE_STATS */ | |
1893 } | |
1894 | |
1895 void | |
1857 init_elhash_once_early (void) | 1896 init_elhash_once_early (void) |
1858 { | 1897 { |
1859 INIT_LISP_OBJECT (hash_table); | 1898 INIT_LISP_OBJECT (hash_table); |
1860 #ifdef NEW_GC | 1899 #ifdef NEW_GC |
1861 INIT_LISP_OBJECT (hash_table_entry); | 1900 INIT_LISP_OBJECT (hash_table_entry); |