reddit / emacs

Intermittent : Emacs not responding (macOS); need suggestions how to find the culprit

emgee_1 · 2022-09-29 13:31
Hi fellow emacsers. Running emacs28.2 (emacs-mac version Mituharu). I have observed many intermittent "hanging" of emacs on macOS for several months. This has not ever happened to me. At first it looked that I could trigger this feature when using mu4e, opening an html message and scrolling with an arrow downwards. This happened often but not immediately. Because I thought maybe this was mu4e related I chose to use a diffrent client (notmuch). Using notmuch the "hanging" did not happen. However, lately I noticed that the "hanging" could happen using consult-ripgrep searching a 2G sharepoint. And now also during just navigating between frames (on laptop and to screens). Q: what things could I do to get an idea what triggers emacs to hang? I do not mind recompiling emacs with special options if needed. Thank you, Marcel
eli-zaretskii · 2022-09-29 15:59
The immediate suspect is GC, especially if you customized the GC thresholds to make them higher. To see if it's GC, set `garbage-collection-messages` non-nil, and see if Emacs says "Garbage collecting..." in the echo area when it "hangs".
na85 · 2022-09-29 20:37
Agreed. I had the same thing after deciding to increase the GC threshold by a considerable amount. 32 megs seems like a happy medium.
emgee_1 · 2022-09-30 06:28
First thank you Eli. I have set to non-nil and see garbage collection happening in the echo-area, but do not see that in \*messages\*. Is this logged at alll? I set the default gc threshold to 100000000. Startup time is much shorter now. I could made it hang using the default threshold but then I am not able to see the message in the echo area. I used also a saved desktop session (M-x desktop-read) which loaded some 240 buffers. (240 buffers 23564479 233 files, 1 process) That could maybe be also problematic. I do mainly literate programming with R and LaTeX. Thanks, Marcel
emgee_1 · 2022-09-30 06:29
I set it to 100000000 but will revert that to your recommendation if the problem persists
eli-zaretskii · 2022-09-30 06:50
> do not see that in *messages*. Is this logged at alll? No, it isn't, and for good reason: inserting text into a buffer during GC is not a good idea when Emacs might be almost out of memory. > I set the default gc threshold to 100000000. Startup time is much shorter now. Startup time is shorter, but GC is much longer, and you run the risk of making the Emacs memory footprint too large. My suggestion is to start from the default and double it until the gain becomes very small; then stop enlarging the threshold. I wouldn't expect you to go beyond 10MB or so. > I could made it hang using the default threshold but then I am not able to see the message in the echo area. This means something other than GC causes that.
emgee_1 · 2022-09-30 07:05
Thanks Eli; I will follow your recommendation. Marcel