annotate lisp/diagnose.el @ 5238:2cc24c69446c

Document the new allocator and the new garbage collector in gc.c and mc-alloc.c.
author Marcus Crestani <crestani@informatik.uni-tuebingen.de>
date Mon, 05 Jul 2010 18:17:39 +0200
parents 4c56e7c6a704
children ed74d2ca7082 308d34e9f07d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2618
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
1 ;;; diagnose.el --- routines for debugging problems in XEmacs
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
2
5059
c8f90d61dcf3 fix memory usage stats to include pdumped objects
Ben Wing <ben@xemacs.org>
parents: 4103
diff changeset
3 ;; Copyright (C) 2002, 2010 Ben Wing.
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
4
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
5 ;; Maintainer: XEmacs Development Team
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
6 ;; Keywords: dumped
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
7
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
8 ;; This file is part of XEmacs.
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
9
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
13 ;; any later version.
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
14
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
18 ;; General Public License for more details.
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
19
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
23 ;; 02111-1307, USA.
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
24
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
25 ;;; Synched up with: Not in FSF.
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
26
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
27 ;;; Commentary:
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
28
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
29 ;; This file is dumped with XEmacs.
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
30
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
31 ;;; Code:
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
32
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
33
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
34 (defun show-memory-usage ()
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
35 "Show statistics about memory usage of various sorts in XEmacs."
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
36 (interactive)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
37 (garbage-collect)
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
38 (flet ((show-foo-stats (objtypename statname-plist cleanfun objlist
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
39 &optional objnamelen)
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
40 (let* ((hash (make-hash-table))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
41 (first t)
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
42 types origtypes fmt
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
43 (objnamelen (or objnamelen 25))
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
44 (linelen objnamelen)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
45 (totaltotal 0))
5157
1fae11d56ad2 redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents: 5059
diff changeset
46 (loop for obj in objlist do
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
47 (let ((total 0)
5157
1fae11d56ad2 redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents: 5059
diff changeset
48 (stats (object-memory-usage obj)))
1fae11d56ad2 redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents: 5059
diff changeset
49 ;; Pop off the slice describing the object itself's
1fae11d56ad2 redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents: 5059
diff changeset
50 ;; memory
1fae11d56ad2 redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents: 5059
diff changeset
51 (while (and stats (not (eq t (pop stats)))))
1fae11d56ad2 redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents: 5059
diff changeset
52 ;; Pop off the slice describing the associated
1fae11d56ad2 redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents: 5059
diff changeset
53 ;; non-Lisp-Object memory from the allocation
1fae11d56ad2 redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents: 5059
diff changeset
54 ;; perspective, so we can get to the slice describing
1fae11d56ad2 redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents: 5059
diff changeset
55 ;; the memory grouped by type
1fae11d56ad2 redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents: 5059
diff changeset
56 (while (and stats (pop stats)))
1fae11d56ad2 redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents: 5059
diff changeset
57
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
58 (loop for (type . num) in (remq t stats) while type do
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
59 (if first (push type origtypes))
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
60 (setq type (getf statname-plist type type))
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
61 (puthash type (+ num (or (gethash type hash) 0)) hash)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
62 (incf total num)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
63 (if first (push type types)))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
64 (incf totaltotal total)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
65 (when first
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
66 (setq types (nreverse types))
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
67 (setq origtypes (nreverse origtypes))
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
68 (setq fmt (concat
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
69 (format "%%-%ds" objnamelen)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
70 (mapconcat
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
71 #'(lambda (type)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
72 (let ((fieldlen
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
73 (max 7 (+ 2 (length
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
74 (symbol-name type))))))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
75 (incf linelen fieldlen)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
76 (format "%%%ds" fieldlen)))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
77 types "")
2618
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
78 (progn (incf linelen 9) "%9s\n")))
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
79 (princ "\n")
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
80 (princ (apply 'format fmt objtypename
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
81 (append types (list 'total))))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
82 (princ (make-string linelen ?-))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
83 (princ "\n"))
5157
1fae11d56ad2 redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents: 5059
diff changeset
84 (let ((objname (format "%s" (funcall cleanfun obj))))
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
85 (princ (apply 'format fmt (substring objname 0
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
86 (min (length objname)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
87 (1- objnamelen)))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
88 (nconc (mapcar #'(lambda (type)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
89 (cdr (assq type stats)))
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
90 origtypes)
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
91 (list total)))))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
92 (setq first nil)))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
93 (princ "\n")
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
94 (princ (apply 'format fmt "total"
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
95 (nconc (mapcar #'(lambda (type)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
96 (gethash type hash))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
97 types)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
98 (list totaltotal))))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
99 totaltotal)))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
100
2618
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
101 (let ((grandtotal 0)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
102 (buffer "*memory usage*")
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
103 begin)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
104 (with-output-to-temp-buffer buffer
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
105 (save-excursion
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
106 (set-buffer buffer)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
107 (when-fboundp 'charset-list
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
108 (setq begin (point))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
109 (incf grandtotal
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
110 (show-foo-stats 'charset nil 'charset-name
5157
1fae11d56ad2 redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents: 5059
diff changeset
111 (mapcar 'get-charset (charset-list))))
3066
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
112 (when-fboundp 'sort-numeric-fields
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
113 (sort-numeric-fields -1
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
114 (save-excursion
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
115 (goto-char begin)
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
116 (forward-line 2)
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
117 (point))
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
118 (save-excursion
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
119 (forward-line -2)
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
120 (point))))
2618
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
121 (princ "\n"))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
122 (setq begin (point))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
123 (incf grandtotal
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
124 (show-foo-stats 'buffer nil 'buffer-name (buffer-list)))
3066
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
125 (when-fboundp 'sort-numeric-fields
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
126 (sort-numeric-fields -1
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
127 (save-excursion
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
128 (goto-char begin)
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
129 (forward-line 3)
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
130 (point))
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
131 (save-excursion
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
132 (forward-line -2)
a88e6130a523 [xemacs-hg @ 2005-11-13 10:56:09 by ben]
ben
parents: 3041
diff changeset
133 (point))))
2618
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
134 (princ "\n")
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
135 (setq begin (point))
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
136 (incf grandtotal
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
137 (show-foo-stats 'window
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
138 '(line-start-cache line-st.
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
139 face-cache face
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
140 glyph-cache glyph
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
141 redisplay-structs redisplay
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
142 scrollbar-instances scrollbar
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
143 window-mirror mirror)
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
144 #'(lambda (x)
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
145 (buffer-name (window-buffer x)))
5157
1fae11d56ad2 redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents: 5059
diff changeset
146 (mapcan #'(lambda (fr)
1fae11d56ad2 redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents: 5059
diff changeset
147 (window-list fr t))
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
148 (frame-list))
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
149 16))
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
150 (when-fboundp #'sort-numeric-fields
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
151 (sort-numeric-fields -1
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
152 (save-excursion
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
153 (goto-char begin)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
154 (forward-line 3)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
155 (point))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
156 (save-excursion
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
157 (forward-line -2)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
158 (point))))
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
159 (princ "\n")
2618
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
160 (let ((total 0)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
161 (fmt "%-30s%10s\n"))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
162 (setq begin (point))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
163 (princ (format fmt "object" "storage"))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
164 (princ (make-string 40 ?-))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
165 (princ "\n")
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
166 (map-plist #'(lambda (stat num)
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
167 (when (and
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
168 (not
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
169 (string-match
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
170 "\\(.*\\)-ancillary-storage$"
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
171 (symbol-name stat)))
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
172 (string-match
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
173 "\\(.*\\)-storage$"
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
174 (symbol-name stat)))
2618
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
175 (incf total num)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
176 (princ (format fmt
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
177 (match-string 1 (symbol-name stat))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
178 num)))
5160
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
179 )
2618
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
180 (sixth (garbage-collect)))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
181 (princ "\n")
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
182 (princ (format fmt "total" total))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
183 (incf grandtotal total))
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
184 (when-fboundp #'sort-numeric-fields
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
185 (sort-numeric-fields -1
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
186 (save-excursion
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
187 (goto-char begin)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
188 (forward-line 2)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
189 (point))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
190 (save-excursion
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
191 (forward-line -2)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
192 (point))))
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
193
2618
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
194 (princ (format "\n\ngrand total: %s\n" grandtotal)))
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
195 grandtotal))))
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
196
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
197
3041
876730d84b73 [xemacs-hg @ 2005-11-02 03:26:51 by crestani]
crestani
parents: 2775
diff changeset
198 (defun show-object-memory-usage-stats ()
3888
099851392ea7 [xemacs-hg @ 2007-03-30 14:38:39 by stephent]
stephent
parents: 3320
diff changeset
199 "Show statistics about object memory usage in XEmacs."
2775
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
200 (interactive)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
201 (garbage-collect)
3041
876730d84b73 [xemacs-hg @ 2005-11-02 03:26:51 by crestani]
crestani
parents: 2775
diff changeset
202 (let ((buffer "*object memory usage statistics*")
876730d84b73 [xemacs-hg @ 2005-11-02 03:26:51 by crestani]
crestani
parents: 2775
diff changeset
203 (plist (object-memory-usage-stats))
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
204 (fmt "%-28s%10s%10s%10s%10s%10s\n")
2775
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
205 (grandtotal 0)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
206 begin)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
207 (flet ((show-stats (match-string)
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
208 (princ (format "%28s%10s%40s\n" "" ""
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
209 "--------------storage---------------"))
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
210 (princ (format fmt "object" "count" "object" "overhead"
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
211 "non-Lisp" "ancillary"))
5160
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
212 (princ (make-string 78 ?-))
2775
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
213 (princ "\n")
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
214 (let ((total-use 0)
5158
9e0b43d3095c more cleanups to object-memory-usage stuff
Ben Wing <ben@xemacs.org>
parents: 5157
diff changeset
215 (total-non-lisp-use 0)
2775
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
216 (total-use-overhead 0)
5160
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
217 (total-use-with-overhead 0)
2775
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
218 (total-count 0))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
219 (map-plist
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
220 #'(lambda (stat num)
5160
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
221 (let ((symmatch
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
222 (and (string-match match-string (symbol-name stat))
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
223 (match-string 1 (symbol-name stat)))))
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
224 (when (and symmatch
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
225 (or (< (length symmatch) 9)
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
226 (not (equal (substring symmatch -9)
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
227 "-non-lisp")))
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
228 (or (< (length symmatch) 15)
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
229 (not (equal (substring symmatch -15)
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
230 "-lisp-ancillary"))))
5160
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
231 (let* ((storage-use num)
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
232 (storage-use-overhead
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
233 (or (plist-get
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
234 plist
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
235 (intern (concat symmatch
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
236 "-storage-overhead")))
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
237 0))
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
238 (storage-use-with-overhead
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
239 (or (plist-get
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
240 plist
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
241 (intern (concat
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
242 symmatch
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
243 "-storage-including-overhead")))
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
244 (+ storage-use storage-use-overhead)))
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
245 (storage-use-overhead
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
246 (- storage-use-with-overhead storage-use))
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
247 (non-lisp-storage
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
248 (or (plist-get
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
249 plist
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
250 (intern (concat symmatch
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
251 "-non-lisp-storage")))
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
252 0))
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
253 (lisp-ancillary-storage
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
254 (or (plist-get
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
255 plist
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
256 (intern (concat symmatch
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
257 "-lisp-ancillary-storage")))
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
258 0))
5160
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
259 (storage-count
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
260 (or (loop for str in '("s-used" "es-used" "-used")
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
261 for val = (plist-get
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
262 plist
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
263 (intern
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
264 (concat symmatch str)))
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
265 if val
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
266 return val)
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
267 (plist-get
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
268 plist
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
269 (intern
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
270 (concat (substring symmatch 0 -1)
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
271 "ies-used")))
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
272 )))
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
273 (incf total-use storage-use)
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
274 (incf total-use-overhead storage-use-overhead)
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
275 (incf total-use-with-overhead storage-use-with-overhead)
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
276 (incf total-non-lisp-use non-lisp-storage)
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
277 (incf total-count (or storage-count 0))
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
278 (and (> storage-use-with-overhead 0)
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
279 (princ (format fmt symmatch
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
280 (or storage-count "unknown")
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
281 storage-use
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
282 storage-use-overhead
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
283 non-lisp-storage
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
284 lisp-ancillary-storage)))))))
2775
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
285 plist)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
286 (princ "\n")
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
287 (princ (format fmt "total"
5160
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
288 total-count total-use total-use-overhead
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
289 total-non-lisp-use ""))
5160
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
290 (incf grandtotal total-use-with-overhead)
ab9ee10a53e4 fix various problems with allocation statistics, track overhead properly
Ben Wing <ben@xemacs.org>
parents: 5158
diff changeset
291 (incf grandtotal total-non-lisp-use)
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
292 (when-fboundp #'sort-numeric-fields
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
293 (sort-numeric-fields -4
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
294 (save-excursion
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
295 (goto-char begin)
5170
5ddbab03b0e6 various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents: 5160
diff changeset
296 (forward-line 4)
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
297 (point))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
298 (save-excursion
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
299 (forward-line -2)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
300 (point)))))))
2775
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
301 (with-output-to-temp-buffer buffer
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
302 (save-excursion
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
303 (set-buffer buffer)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
304 (setq begin (point))
5158
9e0b43d3095c more cleanups to object-memory-usage stuff
Ben Wing <ben@xemacs.org>
parents: 5157
diff changeset
305 (princ "Allocated with lisp allocator or related:\n")
2775
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
306 (show-stats "\\(.*\\)-storage$")
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
307 (princ (format "\n\ngrand total: %s\n" grandtotal)))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
308 grandtotal))))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
309
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
310
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
311 (defun show-mc-alloc-memory-usage ()
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
312 "Show statistics about memory usage of the new allocator."
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
313 (interactive)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
314 (garbage-collect)
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
315 (if-fboundp #'mc-alloc-memory-usage
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
316 (let* ((stats (mc-alloc-memory-usage))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
317 (page-size (first stats))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
318 (heap-sects (second stats))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
319 (used-plhs (third stats))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
320 (free-plhs (fourth stats))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
321 (globals (fifth stats))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
322 (mc-malloced-bytes (sixth stats)))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
323 (with-output-to-temp-buffer "*mc-alloc memory usage*"
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
324 (flet ((print-used-plhs (text plhs)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
325 (let ((sum-n-pages 0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
326 (sum-used-n-cells 0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
327 (sum-used-space 0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
328 (sum-used-total 0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
329 (sum-total-n-cells 0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
330 (sum-total-space 0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
331 (sum-total-total 0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
332 (fmt "%7s%7s|%7s%9s%9s%4s|%7s%9s%9s%4s|%4s\n"))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
333 (princ (format "%-14s|%-29s|%-29s|\n"
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
334 text
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
335 " currently in use"
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
336 " total available"))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
337 (princ (format fmt "cell-sz" "#pages"
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
338 "#cells" "space" "total" "% "
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
339 "#cells" "space" "total" "% " "% "))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
340 (princ (make-string 79 ?-))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
341 (princ "\n")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
342 (while plhs
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
343 (let* ((elem (car plhs))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
344 (cell-size (first elem))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
345 (n-pages (second elem))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
346 (used-n-cells (third elem))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
347 (used-space (fourth elem))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
348 (used-total (if (zerop cell-size)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
349 (sixth elem)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
350 (* cell-size used-n-cells)))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
351 (used-eff (floor (if (not (zerop used-total))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
352 (* (/ (* used-space 1.0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
353 (* used-total 1.0))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
354 100.0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
355 0)))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
356 (total-n-cells (fifth elem))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
357 (total-space (if (zerop cell-size)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
358 used-space
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
359 (* cell-size total-n-cells)))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
360 (total-total (sixth elem))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
361 (total-eff (floor (if (not (zerop total-total))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
362 (* (/ (* total-space 1.0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
363 (* total-total 1.0))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
364 100.0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
365 0)))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
366 (eff (floor (if (not (zerop total-total))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
367 (* (/ (* used-space 1.0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
368 (* total-total 1.0))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
369 100.0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
370 0))))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
371 (princ (format fmt
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
372 cell-size n-pages used-n-cells used-space
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
373 used-total used-eff total-n-cells
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
374 total-space total-total total-eff eff))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
375 (incf sum-n-pages n-pages)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
376 (incf sum-used-n-cells used-n-cells)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
377 (incf sum-used-space used-space)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
378 (incf sum-used-total used-total)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
379 (incf sum-total-n-cells total-n-cells)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
380 (incf sum-total-space total-space)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
381 (incf sum-total-total total-total))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
382 (setq plhs (cdr plhs)))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
383 (let ((avg-used-eff (floor (if (not (zerop sum-used-total))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
384 (* (/ (* sum-used-space 1.0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
385 (* sum-used-total 1.0))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
386 100.0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
387 0)))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
388 (avg-total-eff (floor (if (not (zerop sum-total-total))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
389 (* (/ (* sum-total-space 1.0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
390 (* sum-total-total 1.0))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
391 100.0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
392 0)))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
393 (avg-eff (floor (if (not (zerop sum-total-total))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
394 (* (/ (* sum-used-space 1.0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
395 (* sum-total-total 1.0))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
396 100.0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
397 0))))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
398 (princ (format fmt "sum " sum-n-pages sum-used-n-cells
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
399 sum-used-space sum-used-total avg-used-eff
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
400 sum-total-n-cells sum-total-space
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
401 sum-total-total avg-total-eff avg-eff))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
402 (princ "\n"))))
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
403
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
404
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
405 (print-free-plhs (text plhs)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
406 (let ((sum-n-pages 0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
407 (sum-n-sects 0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
408 (sum-space 0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
409 (sum-total 0)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
410 (fmt "%6s%10s |%7s%10s\n"))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
411 (princ (format "%s\n" text))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
412 (princ (format fmt "#pages" "space" "#sects" "total"))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
413 (princ (make-string 35 ?-))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
414 (princ "\n")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
415 (while plhs
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
416 (let* ((elem (car plhs))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
417 (n-pages (first elem))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
418 (n-sects (second elem))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
419 (space (* n-pages page-size))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
420 (total (* n-sects space)))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
421 (princ (format fmt n-pages space n-sects total))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
422 (incf sum-n-pages n-pages)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
423 (incf sum-n-sects n-sects)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
424 (incf sum-space space)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
425 (incf sum-total total))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
426 (setq plhs (cdr plhs)))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
427 (princ (make-string 35 ?=))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
428 (princ "\n")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
429 (princ (format fmt sum-n-pages sum-space
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
430 sum-n-sects sum-total))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
431 (princ "\n"))))
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
432
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
433 (princ (format "%-12s%10s\n\n" "PAGE_SIZE" page-size))
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
434
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
435 (print-used-plhs "USED HEAP" used-plhs)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
436 (princ "\n\n")
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
437
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
438 (print-free-plhs "FREE HEAP" free-plhs)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
439 (princ "\n\n")
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
440
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
441 (let ((fmt "%-30s%10s\n"))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
442 (princ (format fmt "heap sections" ""))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
443 (princ (make-string 40 ?-))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
444 (princ "\n")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
445 (princ (format fmt "number of heap sects"
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
446 (first heap-sects)))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
447 (princ (format fmt "used size" (second heap-sects)))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
448 (princ (make-string 40 ?-))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
449 (princ "\n")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
450 (princ (format fmt "real size" (third heap-sects)))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
451 (princ (format fmt "global allocator structs" globals))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
452 (princ (make-string 40 ?-))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
453 (princ "\n")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
454 (princ (format fmt "real size + structs"
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
455 (+ (third heap-sects) globals)))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
456 (princ "\n")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
457 (princ (make-string 40 ?=))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
458 (princ "\n")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
459 (princ (format fmt "grand total" mc-malloced-bytes)))
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
460
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
461 (+ mc-malloced-bytes))))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
462 (message "mc-alloc not used in this XEmacs.")))
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3066
diff changeset
463
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3066
diff changeset
464
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3066
diff changeset
465 (defun show-gc-stats ()
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3066
diff changeset
466 "Show statistics about garbage collection cycles."
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3066
diff changeset
467 (interactive)
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
468 (if-fboundp #'gc-stats
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
469 (let ((buffer "*garbage collection statistics*")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
470 (plist (gc-stats))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
471 (fmt "%-9s %16s %12s %12s %12s %12s\n"))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
472 (flet ((plist-get-stat (category field)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
473 (let ((stat (plist-get plist
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
474 (intern (concat category field)))))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
475 (if stat
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
476 (format "%.0f" stat)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
477 "-")))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
478 (show-stats (category)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
479 (princ (format fmt category
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
480 (plist-get-stat category "-total")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
481 (plist-get-stat category "-in-last-gc")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
482 (plist-get-stat category "-in-this-gc")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
483 (plist-get-stat category "-in-last-cycle")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
484 (plist-get-stat category "-in-this-cycle")))))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
485 (with-output-to-temp-buffer buffer
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
486 (save-excursion
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
487 (set-buffer buffer)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
488 (princ (format "%s %g\n" "Current phase"
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
489 (plist-get plist 'phase)))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
490 (princ (make-string 78 ?-))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
491 (princ "\n")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
492 (princ (format fmt "stat" "total" "last-gc" "this-gc"
5230
4c56e7c6a704 Fix a misspelling, diagnose.el.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5170
diff changeset
493 "last-cycle" "this-cycle"))
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
494 (princ (make-string 78 ?-))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
495 (princ "\n")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
496 (show-stats "n-gc")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
497 (show-stats "n-cycles")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
498 (show-stats "enqueued")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
499 (show-stats "dequeued")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
500 (show-stats "repushed")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
501 (show-stats "enqueued2")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
502 (show-stats "dequeued2")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
503 (show-stats "finalized")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
504 (show-stats "freed")
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
505 (plist-get plist 'n-gc-total)))))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3888
diff changeset
506 (error 'void-function "gc-stats not available.")))