Open gh-salt opened 1 year ago
Next time, can you give the output of:
(defun ap/garbage-collect ()
"Run `garbage-collect' and print stats about memory usage."
(interactive)
(message (cl-loop for (type size used free) in (garbage-collect)
for used = (* used size)
for free = (* (or free 0) size)
for total = (file-size-human-readable (+ used free))
for used = (file-size-human-readable used)
for free = (file-size-human-readable free)
concat (format "%s: %s + %s = %s\n" type used free total))))
Here is one run of this function when emacs turns notably slow (it has been for a bit now but it's becoming unmanageable):
conses: 57.9M + 10.6M = 68.5M
symbols: 6.7M + 0 = 6.7M
strings: 12.2M + 1.2M = 13.3M
string-bytes: 10.3M + 0 = 10.3M
vectors: 11.4M + 0 = 11.4M
vector-slots: 51.1M + 8.6M = 59.7M
floats: 19.5k + 17.3k = 36.8k
intervals: 16.1M + 876.4k = 17M
buffers: 31k + 0 = 31k
Here is the result of a small profiling session I did (for about 5 to 8 minutes):
From that alone, it seems like Quail is at fault here. A detailed few of the functions called:
Also notice that the second entry seems to be the garbage collector itself (although some functions are listed from the code of this package):
The third entry (which also seems shocking) comes from me pressing o
in normal mode, I guess.
I don't really understand why it is that slow though:
As for the memory profiling (same session), here it is:
Here are the two most memory-demanding functions:
And then comes Quail:
I do not quite understand why my Emacs slows down that much (globally, any action takes time, even if seemingly unrelated to the Isabelle buffer), but we should have most of the information we need here.
I am wondering if we are seeing here the evil advice or something else:
14938 29% - ad-Advice-read-key-sequence
14876 29% - #<subr read-key-sequence>
1850 3% + #<compiled 0x1d8a69eb401801f9>
414 0% + redisplay_internal (C function)
354 0% + jsonrpc--process-filter
269 0% + timer-event-handler
1 0% internal-timer-start-idle
(Advised here: https://github.com/emacs-evil/evil/blob/2b2ba3cbeabe1f239b6b0ebdaddcb68dd158bd1f/evil-repeat.el#L634)
Okay here is a try. Right before (defun quail-start-translation (key)
from unicode-tokens.el
, add the following line:
(fset 'original-read-key-sequence (symbol-function 'read-key-sequence))
and replace all the read-key-sequence
by original-read-key-sequence
(taken from https://emacs.stackexchange.com/questions/16809/override-a-function-locally-but-allow-calls-to-the-original-function)
Using emacs 28.2 with doom, we observe that everything becomes slower over time. We suspect this is a problem related to the non-deletion of overlays. A potential fix is under investigation:
adding
(overlay-put ov 'evaporate t)
in lsp-isar-decorations.el line 767.