For convenience (at least so far) I am running my program that produces a lot of debug output in Emacs shell.
However I have a problem: Sometimes (not all the time) moving the cursor (up, down, left, right) is terribly slow. I mean seconds until the cursor moves.
I'm using PuTTY to connect via SSH in text mode to a SLES12 SP5 Linux machine (i.e. Emacs 24.3) that runs in VMware.
Once when the cursor did not move for seconds, I noticed in another terminal (that would react at normal speed) that the Emacs process (emacs-gtk
) was at 99% CPU for a long time.
So I disabled line-number-mode
, but that didn't help.
Next I disabled font-lock-mode
, but that also did not help.
The size of the *shell*
buffer is about 7.9MB, the system has 290MB free, 265MB buffers, and 910MB cached, so memory should not be the problem.
I'm somewhat clueless. What could be the problem, and how can I fix it?
I did an ltrace -p <pid_of emacs-gtk
and I saw that a memcmp
with the same four(!) parameters (and a small size like 9) is called all the time while the cursor refuses to move.
Line lengths
As I had been asked about the length of the lines: The lines are not extremely long; I'd say most are shorter than 160 characters, and none should exceed 300 characters. I know that Emacs can be very slow for lines with thousands of characters, but that was not the case.
Moving direction
When trying to reproduce, the effect was not as extreme as it was before, but I noticed that moving the cursor up one line while at the beginning of a line seems significantly slower than moving down the cursor to the next line.
I even had re-enabled line-number-mode
and font-lock-mode
.
This test had a buffer size of roughly 8.9MB with 116000 lines, making an average line length of about 77 characters.
C-h i g (elisp)Profiling
to learn about that.