emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NS port: How to debug excessive garbage collection?


From: Keith David Bershatsky
Subject: Re: NS port: How to debug excessive garbage collection?
Date: Fri, 12 Apr 2019 22:55:42 -0700

Thank you, Eli, for letting me know that my previous test was not the correct 
way to do it.  I added a little bit of code from garbage-collect to 
garbage_collect_1 so that messages to stderr are automatically generated when 
garbage collection occurs.

In all three (3) of the new tests, I used the following Lisp code at the outset 
and then held down the right arrow key (right-char) in the *GNU Emacs* welcome 
buffer:

(progn
  (blink-cursor-mode -1)
  (global-eldoc-mode -1)
  (setq timer-list nil
        timer-idle-list nil))

============================

;;; begin STOCK / UNMODIFIED Emacs

((conses 16 12347 39900)
 (symbols 48 1746 1)
 (strings 32 4057 438)
 (string-bytes 1 117832)
 (vectors 16 3477)
 (vector-slots 8 52314 9400)
 (floats 8 7 17)
 (intervals 56 54 26)
 (buffers 992 9))

;;; end STOCK UNMODIFIED Emacs

============================

;;; begin MODIFIED Emacs -- CROSSHAIRS "OFF"

((conses 16 4624 17450)
 (symbols 48 1312 0)
 (strings 32 580 1807)
 (string-bytes 1 34827)
 (vectors 16 3638)
 (vector-slots 8 52667 12372)
 (floats 8 17 425)
 (intervals 56 51 29)
 (buffers 1072 8))

;;; end MODIFIED Emacs -- CROSSHAIRS "OFF"

============================

;;; begin MODIFIED Emacs -- CROSSHAIRS "ON"

((conses 16 6032 17006)
 (symbols 48 1314 1)
 (strings 32 595 1854)
 (string-bytes 1 36097)
 (vectors 16 3729)
 (vector-slots 8 53337 12722)
 (floats 8 264 805)
 (intervals 56 53 27)
 (buffers 1072 9))

;;; end MODIFIED Emacs -- CROSSHAIRS "ON"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Here is the diff I used to automatically generate messages to stderr during 
garbage collection:

diff --git a/src/alloc.c b/src/alloc.c
index dd78386..b503b74 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6206,6 +6206,53 @@ garbage_collect_1 (struct gcstat *gcst)
 
   *gcst = gcstat;
 
+
+/* *************************************************************************** 
*/
+/* begin DEBUGGING */
+
+  Lisp_Object total[] = {
+    list4 (Qconses, make_fixnum (sizeof (struct Lisp_Cons)),
+           make_int (gcstat.total_conses),
+           make_int (gcstat.total_free_conses)),
+    list4 (Qsymbols, make_fixnum (sizeof (struct Lisp_Symbol)),
+           make_int (gcstat.total_symbols),
+           make_int (gcstat.total_free_symbols)),
+    list4 (Qstrings, make_fixnum (sizeof (struct Lisp_String)),
+           make_int (gcstat.total_strings),
+           make_int (gcstat.total_free_strings)),
+    list3 (Qstring_bytes, make_fixnum (1),
+           make_int (gcstat.total_string_bytes)),
+    list3 (Qvectors,
+           make_fixnum (header_size + sizeof (Lisp_Object)),
+           make_int (gcstat.total_vectors)),
+    list4 (Qvector_slots, make_fixnum (word_size),
+           make_int (gcstat.total_vector_slots),
+           make_int (gcstat.total_free_vector_slots)),
+    list4 (Qfloats, make_fixnum (sizeof (struct Lisp_Float)),
+           make_int (gcstat.total_floats),
+           make_int (gcstat.total_free_floats)),
+    list4 (Qintervals, make_fixnum (sizeof (struct interval)),
+           make_int (gcstat.total_intervals),
+           make_int (gcstat.total_free_intervals)),
+    list3 (Qbuffers, make_fixnum (sizeof (struct buffer)),
+           make_int (gcstat.total_buffers)),
+
+#ifdef DOUG_LEA_MALLOC
+    list4 (Qheap, make_fixnum (1024),
+           make_int ((mallinfo ().uordblks + 1023) >> 10),
+           make_int ((mallinfo ().fordblks + 1023) >> 10)),
+#endif
+  };
+
+  Lisp_Object val = CALLMANY (Flist, total);
+  Lisp_Object string = Fprin1_to_string (val, Qnil);
+  char *char_string = SSDATA (string);
+  fprintf (stderr, "%s\n", char_string);
+
+/* end DEBUGGING */
+/* *************************************************************************** 
*/
+
+
   /* GC is complete: now we can run our finalizer callbacks.  */
   run_finalizers (&doomed_finalizers);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]