unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Keith David Bershatsky <esq@lawlist.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: NS port:  How to debug excessive garbage collection?
Date: Sat, 13 Apr 2019 09:31:21 -0700	[thread overview]
Message-ID: <m25zrhhnom.wl%esq@lawlist.com> (raw)

Thank you, Eli, for directing me to the function memory-use-counts.  I inserted the innards of that function into garbage_collect_1 and ran new tests, selecting the first 5 stderr printouts for each test using the following Lisp command (at the outset of each test) and then holding down the right arrow key (right-char):

(progn
  (find-library "simple")
  (fundamental-mode)
  (blink-cursor-mode -1)
  (global-eldoc-mode -1)
  (setq timer-list nil
        timer-idle-list nil
        crosshairs t))

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

;;; begin STOCK / UNMODIFIED

((cons_cells_consed 2285210)
 (symbols_consed 16084)
 (strings_consed 95613)
 (string_chars_consed 2091140)
 (vector_cells_consed 6877366)
 (floats_consed 568)
 (intervals_consed 112))

((cons_cells_consed 2327648)
 (symbols_consed 16084)
 (strings_consed 97813)
 (string_chars_consed 2106916)
 (vector_cells_consed 6878987)
 (floats_consed 569)
 (intervals_consed 112))

((cons_cells_consed 2370021)
 (symbols_consed 16084)
 (strings_consed 100103)
 (string_chars_consed 2123400)
 (vector_cells_consed 6880233)
 (floats_consed 570)
 (intervals_consed 112))

((cons_cells_consed 2412389)
 (symbols_consed 16084)
 (strings_consed 102389)
 (string_chars_consed 2139936)
 (vector_cells_consed 6881507)
 (floats_consed 571)
 (intervals_consed 112))

((cons_cells_consed 2455285)
 (symbols_consed 16084)
 (strings_consed 104220)
 (string_chars_consed 2152636)
 (vector_cells_consed 6884284)
 (floats_consed 572)
 (intervals_consed 112))


;;; end STOCK UNMODIFIED

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

;;; begin MODIFIED -- CROSSHAIRS "OFF"

((cons_cells_consed 2282540)
 (symbols_consed 16120)
 (strings_consed 95918)
 (string_chars_consed 2094233)
 (vector_cells_consed 6880135)
 (floats_consed 1656)
 (intervals_consed 112))

((cons_cells_consed 2313916)
 (symbols_consed 16120)
 (strings_consed 99976)
 (string_chars_consed 2122818)
 (vector_cells_consed 6885827)
 (floats_consed 7045)
 (intervals_consed 112))

((cons_cells_consed 2345230)
 (symbols_consed 16120)
 (strings_consed 104045)
 (string_chars_consed 2151571)
 (vector_cells_consed 6891513)
 (floats_consed 12446)
 (intervals_consed 112))

((cons_cells_consed 2376738)
 (symbols_consed 16120)
 (strings_consed 108070)
 (string_chars_consed 2179909)
 (vector_cells_consed 6897231)
 (floats_consed 17787)
 (intervals_consed 112))

((cons_cells_consed 2408250)
 (symbols_consed 16120)
 (strings_consed 112081)
 (string_chars_consed 2208228)
 (vector_cells_consed 6903029)
 (floats_consed 23104)
 (intervals_consed 112))

;;; end MODIFIED -- CROSSHAIRS "OFF"

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

;;; begin MODIFIED -- CROSSHAIRS "ON"

((cons_cells_consed 2323418)
 (symbols_consed 16122)
 (strings_consed 98901)
 (string_chars_consed 2116217)
 (vector_cells_consed 6883922)
 (floats_consed 5413)
 (intervals_consed 112))

((cons_cells_consed 2360412)
 (symbols_consed 16122)
 (strings_consed 102038)
 (string_chars_consed 2139422)
 (vector_cells_consed 6887522)
 (floats_consed 9014)
 (intervals_consed 112))

((cons_cells_consed 2397407)
 (symbols_consed 16122)
 (strings_consed 105191)
 (string_chars_consed 2162776)
 (vector_cells_consed 6891122)
 (floats_consed 12615)
 (intervals_consed 112))

((cons_cells_consed 2434401)
 (symbols_consed 16122)
 (strings_consed 108329)
 (string_chars_consed 2185981)
 (vector_cells_consed 6894722)
 (floats_consed 16216)
 (intervals_consed 112))

((cons_cells_consed 2471395)
 (symbols_consed 16122)
 (strings_consed 111473)
 (string_chars_consed 2209234)
 (vector_cells_consed 6898322)
 (floats_consed 19817)
 (intervals_consed 112))

;;; end MODIFIED -- CROSSHAIRS "ON"

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

diff --git a/src/alloc.c b/src/alloc.c
index dd78386..0bd62c7 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[] = {
+    list2 (intern ("cons_cells_consed"), make_int (cons_cells_consed)),
+    list2 (intern ("symbols_consed"), make_int (symbols_consed)),
+    list2 (intern ("strings_consed"), make_int (strings_consed)),
+    list2 (intern ("string_chars_consed"), make_int (string_chars_consed)),
+    list2 (intern ("vector_cells_consed"), make_int (vector_cells_consed)),
+    list2 (intern ("floats_consed"), make_int (floats_consed)),
+    list2 (intern ("intervals_consed"), make_int (intervals_consed)),
+/*
+    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	other threads:[~2019-04-13 16:31 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-13 16:31 Keith David Bershatsky [this message]
2019-04-13 17:02 ` NS port: How to debug excessive garbage collection? Alex Gramiak
  -- strict thread matches above, loose matches on Subject: below --
2019-04-16  5:51 Keith David Bershatsky
2019-04-16  2:57 Keith David Bershatsky
2019-04-16  5:26 ` Alex Gramiak
2019-04-15  5:19 Keith David Bershatsky
2019-04-15  2:55 Keith David Bershatsky
2019-04-15  3:44 ` Alex Gramiak
2019-04-14 19:46 Keith David Bershatsky
2019-04-14 23:31 ` Alex Gramiak
2019-04-14  7:41 Keith David Bershatsky
2019-04-13 18:07 Keith David Bershatsky
2019-04-13 21:41 ` Alex Gramiak
2019-04-14  3:47 ` Daniel Colascione
2019-04-13  5:55 Keith David Bershatsky
2019-04-13  6:48 ` Eli Zaretskii
2019-04-11 23:04 Keith David Bershatsky
2019-04-12  9:30 ` Eli Zaretskii
2019-04-11  3:27 Keith David Bershatsky
2019-04-11 14:14 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m25zrhhnom.wl%esq@lawlist.com \
    --to=esq@lawlist.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).