Subject: bug#21453: When font size is temporarily increased Emacs is slow

From: Eli Zaretskii <[email-masked]>
Date: Mon, 28 Sep 2015 14:57:07 +0300

> From: Mark Karpov <[email-masked]>
> Cc: [email-masked]
> Date: Sun, 27 Sep 2015 17:02:12 +0600
> 
> The Results
> ===========
> 
> Here I post measured times:
> 
>   Font Size       Time in Seconds
>   normal           301.423
>   +1              1055.157
>   -1               487.935

I see something very different on my system, so this could be specific
to X or even your font back-end (xft).

Here are my times:

  Font Size       Time in Seconds
                   ELisp  Fundamental
  normal           139.9  113.2
  +1               140.4  112.2
  -1               282.0  126.4
  -2                      148.8
  +2                      114.4

The second column of numbers is with the same file, but with font-lock
turned off, after rejecting the file-local variables, and in
Fundamental mode.  As you see, the differences are much smaller in
Fundamental mode.  This points to face remapping as the possible
reason for slower redisplay, at least in my case.  When you enlarge or
decrease the default font size, Emacs needs to look up the faces in
face-remapping-alist each time it needs to redisplay something, which
could explain some slowdown.

I don't know why the +1 case is so much slower on your system; perhaps
you could use some kind of profiler to see what takes most of the time
in that case.  You could start with the Emacs's built-in profiler,
although I doubt it will tell something revealing, because I think the
reason is below the level the built-in profiler can look.

In any case, I understand now why you perceive the slowdown as
significant: if it takes 1000 sec to scroll through a 8000-line file,
it means you get just 8 lines-per-second, which is slow enough to
annoy.  As you see, on my system, I get 5 times faster performance,
which is below human annoyance threshold.