unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: chiaki-ishikawa-thunderbird-account <chiaki.ishikawa@ubin.jp>
To: Noam Postavsky <npostavs@gmail.com>
Cc: chiaki-ishikawa-thunderbird-account <chiaki.ishikawa@ubin.jp>,
	39413@debbugs.gnu.org
Subject: bug#39413: 26.2; Emacs gets hung
Date: Mon, 8 Jun 2020 17:17:00 +0900	[thread overview]
Message-ID: <45a7b4f2-9065-5dbe-0c7d-c78703b8e95e@ubin.jp> (raw)
In-Reply-To: <ddb74f7f-ba4f-8fe7-377a-81d544dfe3bb@ubin.jp>

On 2020/05/26 0:50, chiaki-ishikawa-thunderbird-account wrote:
> On 2020/05/25 21:15, Noam Postavsky wrote:
>> chiaki-ishikawa-thunderbird-account <chiaki.ishikawa@ubin.jp> writes:
>>
>>> Short of lisp function, maybe I can add message print out in alloc.c
>>> to print out such information so that it gets recorded in *Message*
>>> buffer.
>>> It is done only when gabage-collection-message is t and there should
>>> be some throttling mechanism to avoid spamming the user.
>>> Any pointer re the hook(s) short of rewriting alloc.c is
>>> appreciated. Well, if worst comes to worst, I don't mind rewriting
>>> alloc.c to create an array of fixed size to store the last dozen or so
>>> GC-related information that is updated before and after invocation of
>>> a certain GC entry point.
>>> I can print that out after a long GC to learn the memory situation.
>>> But that sounds a bit drastic. OTOH, it may be the only way to go.
>> That should probably work.  I see the current
>> garbage_collection_messages code uses message_nolog, I guess because
>> growing the *Messages* buffer could also trigger GC.
>>
> Thank you, I will probably do that.
>
> Back in 18.x days, printing the message from within GC caused another 
> GC invocation, thus emacs blew up due to stack flow after so many 
> recursive calls.
>
> I think having a static array of 10-20 cells to store previous GC info 
> should work.
>
> Stay tuned. I am really interested in WHERE/WHY this long pause 
> occurs.: maybe Windows 10 memory allocation/ Virtual Box 
> emulation/Linux kernel memory allocation, and AMD Ryzen CPU's cache 
> replacement policy all add up.
>
> Chiaki
>
>
Hi,

After looking at alloc.c, I realized that there *IS* a post-hook that 
gets called after GC.

So instead of hacking and modifying alloc.c, I took the easy route and 
did the following in my .emacs
(the code is in postscript)
and now waiting for the next LOOONG gc behavior.

Basically I record some GC-related statistics for the last 10 
invocations, and make sure it is recorded in *Messages* buffer.
Maybe I can learn something from it. (My most suspicious part is string 
GC. When I run "erase-buffer" on the "*shell*" buffer which has 
accumulated a large build output a few times over, GC tends to be very 
longish.)

If you know any other easily obtainable GC-related information that 
ought to be in the statistics
on top of
(append (memory-use-counts) (list gc-elapsed gcs-done))
please let me know.

Directly evaluating (garbage-collect) prints a neat result, but I am not 
sure if that can be easily simulated from ordinary eval.
(And maybe it is only syntactic sugar and doesn't add much to the 
necessary statistical data.)

TIA

Chiaki Ishikawa


PS: The addition in my .emacs
;;;
;;; GC behavior monitor
;;;
;;; Record some key information for GC in the GC post-hook so that I
;;; can learn something about the behavior and performance of GC with
;;; concrete data.

(setq my-gc-statistics (make-vector 10 nil))

;;; The element is
;;; (append (memory-use-counts) (list gc-elapsed gcs-done))
;;; Each time the following function is called, the
;;; elements in the array is shifted toward the end.
;;; Use (message "%S" my-gc-statistics) to force the
;;; recording of my-gc-statistics value in *Messages* buffer for later 
analysis.


(defun update-my-gc-statistics ()
   (let ((i 8))
     (progn
      ;;; very unlike Lisp
      (while (<= 0 i)
        (progn (aset my-gc-statistics (+ 1 i) (aref my-gc-statistics i))
              (setq i (- i 1) )))
      (aset my-gc-statistics 0
            (append (memory-use-counts) (list gc-elapsed gcs-done)))
      (message "%S" my-gc-statistics))))

(setq post-gc-hook 'update-my-gc-statistics)









  reply	other threads:[~2020-06-08  8:17 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-04  9:32 bug#39413: 26.2; Emacs gets hung chiaki-ishikawa-thunderbird-account
2020-02-04 15:33 ` Eli Zaretskii
2020-02-05  1:11   ` chiaki-ishikawa-thunderbird-account
2020-02-21 17:27 ` Noam Postavsky
2020-02-22 17:53   ` chiaki-ishikawa-thunderbird-account
2020-04-28 21:36     ` ISHIKAWA,chiaki
2020-04-29  6:55       ` Eli Zaretskii
2020-04-30  2:45         ` chiaki-ishikawa-thunderbird-account
2020-05-20  4:31           ` chiaki-ishikawa-thunderbird-account
2020-05-25 12:15             ` Noam Postavsky
2020-05-25 15:50               ` chiaki-ishikawa-thunderbird-account
2020-06-08  8:17                 ` chiaki-ishikawa-thunderbird-account [this message]
2021-08-10 16:09                 ` Lars Ingebrigtsen
2021-08-11  1:08                   ` ISHIKAWA,chiaki
2021-08-11  6:07                     ` ISHIKAWA,chiaki
2021-08-11  7:22                       ` ISHIKAWA,chiaki
2021-08-11 11:14                       ` Lars Ingebrigtsen
2021-08-11 13:46                         ` ISHIKAWA,chiaki
2021-08-11 11:47                       ` Eli Zaretskii
2021-08-11 13:41                         ` ISHIKAWA,chiaki
2021-08-12  7:10                           ` Eli Zaretskii
2021-08-15 23:27                             ` ISHIKAWA,chiaki
2021-08-16  0:20                               ` ISHIKAWA,chiaki
2021-08-16 11:35                               ` Eli Zaretskii
2021-08-20  1:56                                 ` ISHIKAWA,chiaki
2021-09-17 14:49                                   ` Lars Ingebrigtsen
2021-10-18  9:00                                     ` Lars Ingebrigtsen
2021-10-19  7:04                                       ` ISHIKAWA,chiaki

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=45a7b4f2-9065-5dbe-0c7d-c78703b8e95e@ubin.jp \
    --to=chiaki.ishikawa@ubin.jp \
    --cc=39413@debbugs.gnu.org \
    --cc=npostavs@gmail.com \
    /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).