GNU bug report logs - #26402
25.2; Font rendering extremely slow on any non-default font

Previous Next

Package: emacs;

Reported by: Gennady Uraltsev <gennady.uraltsev <at> gmail.com>

Date: Sat, 8 Apr 2017 13:50:02 UTC

Severity: normal

Found in version 25.2

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 26402 in the body.
You can then email your comments to 26402 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#26402; Package emacs. (Sat, 08 Apr 2017 13:50:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Gennady Uraltsev <gennady.uraltsev <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 08 Apr 2017 13:50:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Gennady Uraltsev <gennady.uraltsev <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.2; Font rendering extremely slow on any non-default font
Date: Sat, 8 Apr 2017 15:48:38 +0200
[Message part 1 (text/plain, inline)]
Font rendering in emacs is incredibly slow if any buffer-local change is
made i.e. unless using 'default.

I tried moving the cursor in a small (30 line) text file in emacs under
X. It works perfectly, also changing the default font size with

set-face-font or set-frame-font

works perfectly well. On the other hand, any buffer local change of font
makes everything extremely slow. These modifications include
(buffer-face-set 'fixed-pitch)

or

text-scale-adjust

The cursor gets redrawn around once every second making using emacs
impossible.

I am attaching the profiler logs for moving the cursor from the
beginning to the end of the 30 line buffer


Default run:
> - command-execute                                                 122  96%
>  - call-interactively                                             122  96%
>   - byte-code                                                      88  69%
>    - read-extended-command                                         88  69%
>     - completing-read                                              88  69%
>      - completing-read-default                                     88  69%
>       - read-from-minibuffer                                       25  19%
>        - redisplay_internal (C function)                            3   2%
>         - funcall                                                   3   2%
>          - #<compiled 0x26fa55>                                     3   2%
>           - gui-backend-selection-exists-p                          3   2%
>            - apply                                                  3   2%
>               #<compiled 0x49fcad>                                  3   2%
>        - command-execute                                            2   1%
>         - call-interactively                                        2   1%
>          - funcall-interactively                                    2   1%
>           - previous-line-or-history-element                        2   1%
>            - previous-history-element                               2   1%
>               goto-history-element                                  2   1%
>   - funcall-interactively                                          34  26%
>    - execute-extended-command                                      33  26%
>     - sit-for                                                      25  19%
>      - redisplay                                                   20  15%
>       - redisplay_internal (C function)                             4   3%
>        - funcall                                                    4   3%
>         - #<compiled 0x26fa55>                                      4   3%
>          - gui-backend-selection-exists-p                           4   3%
>           - apply                                                   4   3%
>              #<compiled 0x49fcad>                                   4   3%
>     - command-execute                                               8   6%
>      - call-interactively                                           8   6%
>       - funcall-interactively                                       8   6%
>        - profiler-report                                            8   6%
>         - profiler-report-cpu                                       8   6%
>            profiler-cpu-profile                                     8   6%
>    - next-line                                                      1   0%
>     - line-move                                                     1   0%
>      - line-move-partial                                            1   0%
>       - window-screen-lines                                         1   0%
>        - window-inside-pixel-edges                                  1   0%
>           window-edges                                              1   0%
> - ...                                                               4   3%
>    Automatic GC                                                     4   3%

Run after set-frame-font:

> - command-execute                                                 100  90%
>  - call-interactively                                             100  90%
>   - byte-code                                                      58  52%
>    - read-extended-command                                         58  52%
>     - completing-read                                              58  52%
>      + completing-read-default                                     58  52%
>   - funcall-interactively                                          42  37%
>    - execute-extended-command                                      36  32%
>     - sit-for                                                      24  21%
>      - redisplay                                                   17  15%
>       - redisplay_internal (C function)                             2   1%
>        - funcall                                                    2   1%
>         - #<compiled 0x26fa55>                                      2   1%
>          - gui-backend-selection-exists-p                           2   1%
>           - apply                                                   2   1%
>              #<compiled 0x49fcad>                                   2   1%
>     - command-execute                                              12  10%
>      - call-interactively                                          12  10%
>       - funcall-interactively                                      12  10%
>        - profiler-report                                           12  10%
>         - profiler-report-cpu                                      12  10%
>            profiler-cpu-profile                                    12  10%
>    - next-line                                                      6   5%
>     - line-move                                                     6   5%
>        line-move-visual                                             6   5%
> - ...                                                              10   9%
>    Automatic GC                                                    10   9%
> - timer-event-handler                                               1   0%
>  - apply                                                            1   0%
>     jit-lock-context-fontify                                        1   0%

BAD run after text-scale-adjust

> - command-execute                                                2024  99%
>  - call-interactively                                            2024  99%
>   - funcall-interactively                                        1999  98%
>    - next-line                                                   1965  96%
>     - line-move                                                  1965  96%
>      - line-move-partial                                         1433  70%
>       - default-line-height                                       730  35%
>          default-font-height                                      730  35%
>       - window-screen-lines                                       695  34%
>        - default-line-height                                      691  33%
>           default-font-height                                     691  33%
>        - window-inside-pixel-edges                                  4   0%
>           window-edges                                              4   0%
>       - window-inside-pixel-edges                                   8   0%
>        - window-edges                                               8   0%
>         - window-current-scroll-bars                                4   0%
>            frame-current-scroll-bars                                4   0%
>      - default-line-height                                        524  25%
>         default-font-height                                       524  25%
>        line-move-visual                                             4   0%
>      - window-inside-pixel-edges                                    4   0%
>       - window-edges                                                4   0%
>        - window-current-scroll-bars                                 4   0%
>           frame-current-scroll-bars                                 4   0%
>    - execute-extended-command                                      34   1%
>     - sit-for                                                      22   1%
>        redisplay                                                   16   0%
>     - command-execute                                              12   0%
>      - call-interactively                                          12   0%
>       - funcall-interactively                                      12   0%
>        - profiler-report                                           12   0%
>         - profiler-report-cpu                                      12   0%
>            profiler-cpu-profile                                    12   0%
>   - byte-code                                                      25   1%
>    - read-extended-command                                         25   1%
>     - completing-read                                              25   1%
>      - completing-read-default                                     25   1%
>         read-from-minibuffer                                       19   0%
> - ...                                                              11   0%
>    Automatic GC                                                    11   0%

BAD run after (buffer-set-face fixed-pitch)

> command-execute                                                1778  99%
>  - call-interactively                                            1778  99%
>   - funcall-interactively                                        1745  97%
>    - next-line                                                   1716  96%
>     - line-move                                                  1716  96%
>      - line-move-partial                                         1176  65%
>       - default-line-height                                       608  34%
>          default-font-height                                      608  34%
>       - window-screen-lines                                       568  31%
>        - default-line-height                                      568  31%
>           default-font-height                                     568  31%
>      - default-line-height                                        540  30%
>         default-font-height                                       540  30%
>    - execute-extended-command                                      29   1%
>     - sit-for                                                      15   0%
>        redisplay                                                   12   0%
>     - command-execute                                              14   0%
>      - call-interactively                                          14   0%
>       - funcall-interactively                                      14   0%
>        - profiler-report                                           10   0%
>         - profiler-report-cpu                                      10   0%
>            profiler-cpu-profile                                    10   0%
>          profiler-start                                             4   0%
>   - byte-code                                                      33   1%
>    - read-extended-command                                         33   1%
>     - completing-read                                              33   1%
>      - completing-read-default                                     33   1%
>         read-from-minibuffer                                       17   0%
> - ...                                                               8   0%
>    Automatic GC                                                     8   0%





In GNU Emacs 25.2.1 (x86_64-suse-linux-gnu, GTK+ Version 3.20.10)
 of 2017-03-27 built on lamb61
Windowing system distributor 'The X.Org Foundation', version 11.0.11803000
System Description:	openSUSE Leap 42.2

Configured using:
 'configure --with-pop --without-hesiod --with-kerberos --with-kerberos5
 --with-xim --with-wide-int --with-file-notification=inotify
 --with-modules --enable-autodepend --prefix=/usr
 --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share
 --localstatedir=/var --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --enable-locallisppath=/usr/share/emacs/25.2/site-lisp:/usr/share/emacs/site-lisp
 --with-x --with-sound --with-xpm --with-jpeg --with-tiff --with-gif
 --with-png --with-rsvg --with-dbus --with-xft --without-gpm
 --with-x-toolkit=gtk3 --with-xwidgets --x-includes=/usr/include
 --x-libraries=/usr/lib64 --with-libotf --with-m17n-flt
 --build=x86_64-suse-linux 'CFLAGS=-fmessage-length=0
 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector
 -funwind-tables -fasynchronous-unwind-tables -g -D_GNU_SOURCE
 -DGDK_DISABLE_DEPRECATION_WARNINGS -DGLIB_DISABLE_DEPRECATION_WARNINGS
 -pipe -Wno-pointer-sign -Wno-unused-variable -Wno-unused-label
 -Wno-unprototyped-calls -fno-optimize-sibling-calls -fno-PIE
 -DSYSTEM_PURESIZE_EXTRA=55000 -DSITELOAD_PURESIZE_EXTRA=10000 '
 LDFLAGS=-Wl,-O2'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GCONF GSETTINGS NOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES XWIDGETS

Important settings:
  value of $LC_CTYPE: en_US.UTF-8
  value of $LC_MONETARY: de_DE.UTF-8
  value of $LC_NUMERIC: POSIX
  value of $LC_TIME: en_GB.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=local
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  buffer-face-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
Making completion list... [2 times]
delete-backward-char: Text is read-only
Making completion list... [3 times]
You can run the command ‘buffer-face-set’ with M-x bu-s RET
previous-line: Beginning of buffer [3 times]
CPU profiler stopped
CPU profiler started
next-line: End of buffer
Wrote /home/guraltsev/admin/bugs/emacs/font-slow/buffer-set-face-fixed-pitch
C-x <up> is undefined [2 times]

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message dired format-spec rfc822 mml
mml-sec password-cache epg epg-config gnus-util mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util help-fns help-mode mail-prsvr
mail-utils thingatpt profiler easymenu cl-loaddefs pcase cl-lib
face-remap time-date mule-util delsel lpr tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
dbusbind inotify dynamic-setting system-font-setting font-render-setting
xwidget-internal move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 121417 15744)
 (symbols 48 22660 0)
 (miscs 40 5039 157)
 (strings 32 23137 10436)
 (string-bytes 1 677307)
 (vectors 16 67484)
 (vector-slots 8 1659575 10120)
 (floats 8 184 184)
 (intervals 56 446 10)
 (buffers 976 24)
 (heap 1024 58366 8411))
[BAD-text-scale-adjust-profile (text/plain, attachment)]
[BAD-buffer-set-face-fixed-pitch-profile (text/plain, attachment)]
[GOOD-default-profile (text/plain, attachment)]
[GOOD-set-frame-font-profile (text/plain, attachment)]
[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26402; Package emacs. (Sat, 08 Apr 2017 14:45:01 GMT) Full text and rfc822 format available.

Message #8 received at 26402 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Gennady Uraltsev <gennady.uraltsev <at> gmail.com>
Cc: 26402 <at> debbugs.gnu.org
Subject: Re: bug#26402: 25.2;
 Font rendering extremely slow on any non-default font
Date: Sat, 08 Apr 2017 17:44:48 +0300
> From: Gennady Uraltsev <gennady.uraltsev <at> gmail.com>
> Date: Sat, 8 Apr 2017 15:48:38 +0200
> 
> Font rendering in emacs is incredibly slow if any buffer-local change is
> made i.e. unless using 'default.

Does setting inhibit-compacting-font-caches non-nil solve the problem?
If it does, can you show an example of a buffer where you see this
problem?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26402; Package emacs. (Sat, 08 Apr 2017 14:56:01 GMT) Full text and rfc822 format available.

Message #11 received at 26402 <at> debbugs.gnu.org (full text, mbox):

From: Gennady Uraltsev <gennady.uraltsev <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 26402 <at> debbugs.gnu.org
Subject: Re: bug#26402: 25.2; Font rendering extremely slow on any non-default
 font
Date: Sat, 8 Apr 2017 16:54:54 +0200
[Message part 1 (text/plain, inline)]
Hey,

Nope, sorry. Doesn't seem to help.  What I did:
started emacs with

#emacs -Q lorem-ipsum

emacs opens in fundamental mode with the file (attached)

# M-x eval-expression
# (setq inhibit-compacting-font-caches t)
# buffer-face-set
# variable-pitch

Slow as before. Attaching the profiler logs


On 08/04/17 16:44, Eli Zaretskii wrote:
> > From: Gennady Uraltsev <gennady.uraltsev <at> gmail.com>
> > Date: Sat, 8 Apr 2017 15:48:38 +0200
> >
> > Font rendering in emacs is incredibly slow if any buffer-local change is
> > made i.e. unless using 'default.
>
> Does setting inhibit-compacting-font-caches non-nil solve the problem?
> If it does, can you show an example of a buffer where you see this
> problem?
>

[BAD-inhibit-cache-buffer-set-face-profile (text/plain, attachment)]
[BAD-inhibit-cache-buffer-set-face (text/plain, attachment)]
[lore-ipsum (text/plain, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26402; Package emacs. (Sat, 08 Apr 2017 16:11:01 GMT) Full text and rfc822 format available.

Message #14 received at 26402 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Gennady Uraltsev <gennady.uraltsev <at> gmail.com>
Cc: 26402 <at> debbugs.gnu.org
Subject: Re: bug#26402: 25.2; Font rendering extremely slow on any non-default
 font
Date: Sat, 08 Apr 2017 19:10:41 +0300
> From: Gennady Uraltsev <gennady.uraltsev <at> gmail.com>
> Cc: 26402 <at> debbugs.gnu.org
> Date: Sat, 8 Apr 2017 16:54:54 +0200
> 
> #emacs -Q lorem-ipsum
> 
> emacs opens in fundamental mode with the file (attached)
> 
> # M-x eval-expression
> # (setq inhibit-compacting-font-caches t)
> # buffer-face-set
> # variable-pitch
> 
> Slow as before. Attaching the profiler logs

What font do you get when you do the above?  You can use "C-u C-x ="
to see that.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26402; Package emacs. (Sat, 08 Apr 2017 17:19:02 GMT) Full text and rfc822 format available.

Message #17 received at 26402 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Gennady Uraltsev <gennady.uraltsev <at> gmail.com>
Cc: 26402 <at> debbugs.gnu.org
Subject: Re: bug#26402: 25.2; Font rendering extremely slow on any non-default
 font
Date: Sat, 08 Apr 2017 20:18:15 +0300
[Please keep the bug address on the CC list.]

> From: Gennady Uraltsev <gennady.uraltsev <at> gmail.com>
> Date: Sat, 8 Apr 2017 18:32:34 +0200
> 
> The default font that emacs -Q starts with is
> 
> xft:-adobe-Source Code
> Pro-normal-normal-normal-*-15-*-*-*-m-0-iso10646-1 (#x2C)
> 
> (I guess it comes from the fact that that is my predefined qt and gtk
> monospace font)
> 
> once zooming in (text-scale-adjust INC) I get
> 
> xft:-adobe-Source Code
> Pro-normal-normal-normal-*-18-*-*-*-m-0-iso10646-1 (#x1E)
> 
> If instead of zooming in I do M-x buffer-face-set variable-pitch
> I get the font
> 
>   xft:-unknown-Roboto-normal-normal-normal-*-15-*-*-*-*-0-iso10646-1 (#x48)
> 
> 
> 
> I can also replicate this by setting the global font to be something
> else like
> 
> xft:-unknown-Droid Sans-normal-normal-normal-*-15-*-*-*-*-0-iso10646-1
> (#x54)
> xft:-monotype-Noto Sans-normal-normal-normal-*-15-*-*-*-*-0-iso10646-1
> (#x36)
> 
> at the level of the frame by using
> 
> M-x set-frame-font
> -unknown-Droid Sans-normal-normal-normal-*-*-*-*-*-*-0-iso10646-1
> or
> -monotype-Noto Sans-normal-normal-normal-*-*-*-*-*-*-0-iso10646-1
> 
> respectively. This does not have a negative impact on performance. But
> as soon as I enable  something like
> 
> M-x buffer-face-set fixed-pitch or
> (text-scale-adjust INC) the problem returns

Can you build your own Emacs?  If so, could you please apply the
following patch and see if it solves the problem?

diff --git a/src/font.c b/src/font.c
index a929509..bb6d18b 100644
--- a/src/font.c
+++ b/src/font.c
@@ -2777,21 +2777,22 @@ font_list_entities (struct frame *f, Lisp_Object spec)
 	  val = XCDR (val);
 	else
 	  {
-	    val = driver_list->driver->list (f, scratch_font_spec);
-	    if (!NILP (val))
-	      {
-		Lisp_Object copy = copy_font_spec (scratch_font_spec);
+	    Lisp_Object copy;
 
-		val = Fvconcat (1, &val);
-		ASET (copy, FONT_TYPE_INDEX, driver_list->driver->type);
-		XSETCDR (cache, Fcons (Fcons (copy, val), XCDR (cache)));
-	      }
+	    val = driver_list->driver->list (f, scratch_font_spec);
+	    if (NILP (val))
+	      val = zero_vector;
+	    else
+	      val = Fvconcat (1, &val);
+	    copy = copy_font_spec (scratch_font_spec);
+	    ASET (copy, FONT_TYPE_INDEX, driver_list->driver->type);
+	    XSETCDR (cache, Fcons (Fcons (copy, val), XCDR (cache)));
 	  }
-	if (VECTORP (val) && ASIZE (val) > 0
+	if (ASIZE (val) > 0
 	    && (need_filtering
 		|| ! NILP (Vface_ignored_fonts)))
 	  val = font_delete_unmatched (val, need_filtering ? spec : Qnil, size);
-	if (VECTORP (val) && ASIZE (val) > 0)
+	if (ASIZE (val) > 0)
 	  list = Fcons (val, list);
       }
 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26402; Package emacs. (Sat, 08 Apr 2017 22:34:02 GMT) Full text and rfc822 format available.

Message #20 received at 26402 <at> debbugs.gnu.org (full text, mbox):

From: Gennady Uraltsev <gennady.uraltsev <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 26402 <at> debbugs.gnu.org
Subject: Re: bug#26402: 25.2; Font rendering extremely slow on any non-default
 font
Date: Sun, 9 Apr 2017 00:33:23 +0200
[Message part 1 (text/plain, inline)]
[Sorry about the CC, must have escaped me]

I recompiled from latest git of today so emacs decalres version 26.0.50
I tried recompiling without your patch and also with your patch. No
apparent improvement

I tried running both (text-scale-adjust INC) and buffer-set-face
both with and without (setq inhibit-compacting-font-caches t)

The profiler profiles are attached.
The profiler output for moving the cursor down from the beginning of the
file to the end are as follows:

*****************
M-x buffer-set-face variable-width
without (setq inhibit-compacting-font-caches t)
*****************
> - command-execute                                                2227  99%
>  - call-interactively                                            2227  99%
>   - funcall-interactively                                        2189  98%
>    - next-line                                                   2176  97%
>     - line-move                                                  2176  97%
>      - line-move-partial                                         1560  69%
>       - default-line-height                                       808  36%
>          default-font-height                                      808  36%
>       - window-screen-lines                                       752  33%
>        - default-line-height                                      752  33%
>           default-font-height                                     752  33%
>      - default-line-height                                        616  27%
>         default-font-height                                       612  27%
>       - display-graphic-p                                           4   0%
>          framep-on-display                                          4   0%
>    - execute-extended-command                                      13   0%
>     - sit-for                                                      13   0%
>        redisplay                                                    8   0%
>   - byte-code                                                      34   1%
>    - read-extended-command                                         34   1%
>     - completing-read                                              34   1%
>      - completing-read-default                                     34   1%
>       - read-from-minibuffer                                       17   0%
>        - window--sanitize-window-sizes                              5   0%
>         - walk-window-tree                                          5   0%
>          - walk-window-tree-1                                       5   0%
>           - #<compiled 0x4a56e9>                                    5   0%
>              window-min-size                                        5   0%
> - ...                                                               4   0%
>    Automatic GC                                                     4   0%


*****************
M-x buffer-set-face variable-width
with (setq inhibit-compacting-font-caches t)
*****************

> - command-execute                                                2509  99%
>  - call-interactively                                            2509  99%
>   - funcall-interactively                                        2459  97%
>    - next-line                                                   2415  96%
>     - line-move                                                  2415  96%
>      - line-move-partial                                         1763  70%
>       - default-line-height                                       887  35%
>          default-font-height                                      887  35%
>       - window-screen-lines                                       876  34%
>        - default-line-height                                      876  34%
>           default-font-height                                     876  34%
>      - default-line-height                                        652  25%
>         default-font-height                                       652  25%
>    - execute-extended-command                                      44   1%
>     - sit-for                                                      23   0%
>      - redisplay                                                   12   0%
>       - redisplay_internal (C function)                             4   0%
>          kill-this-buffer-enabled-p                                 4   0%
>     - command-execute                                              21   0%
>      - call-interactively                                          21   0%
>       - funcall-interactively                                      21   0%
>        - profiler-report                                           21   0%
>         - profiler-report-cpu                                      21   0%
>            profiler-cpu-profile                                    21   0%
>   - byte-code                                                      50   1%
>    - read-extended-command                                         50   1%
>     - completing-read                                              50   1%
>      - completing-read-default                                     50   1%
>       - read-from-minibuffer                                       21   0%
>        - command-execute                                            3   0%
>         - call-interactively                                        3   0%
>          - funcall-interactively                                    3   0%
>             delete-backward-char                                    3   0%
> - ...                                                               5   0%
>    Automatic GC                                                     5   0%





On 08/04/17 19:18, Eli Zaretskii wrote:
> [Please keep the bug address on the CC list.]
> 
>> From: Gennady Uraltsev <gennady.uraltsev <at> gmail.com>
>> Date: Sat, 8 Apr 2017 18:32:34 +0200
>>
>> The default font that emacs -Q starts with is
>>
>> xft:-adobe-Source Code
>> Pro-normal-normal-normal-*-15-*-*-*-m-0-iso10646-1 (#x2C)
>>
>> (I guess it comes from the fact that that is my predefined qt and gtk
>> monospace font)
>>
>> once zooming in (text-scale-adjust INC) I get
>>
>> xft:-adobe-Source Code
>> Pro-normal-normal-normal-*-18-*-*-*-m-0-iso10646-1 (#x1E)
>>
>> If instead of zooming in I do M-x buffer-face-set variable-pitch
>> I get the font
>>
>>   xft:-unknown-Roboto-normal-normal-normal-*-15-*-*-*-*-0-iso10646-1 (#x48)
>>
>>
>>
>> I can also replicate this by setting the global font to be something
>> else like
>>
>> xft:-unknown-Droid Sans-normal-normal-normal-*-15-*-*-*-*-0-iso10646-1
>> (#x54)
>> xft:-monotype-Noto Sans-normal-normal-normal-*-15-*-*-*-*-0-iso10646-1
>> (#x36)
>>
>> at the level of the frame by using
>>
>> M-x set-frame-font
>> -unknown-Droid Sans-normal-normal-normal-*-*-*-*-*-*-0-iso10646-1
>> or
>> -monotype-Noto Sans-normal-normal-normal-*-*-*-*-*-*-0-iso10646-1
>>
>> respectively. This does not have a negative impact on performance. But
>> as soon as I enable  something like
>>
>> M-x buffer-face-set fixed-pitch or
>> (text-scale-adjust INC) the problem returns
> 
> Can you build your own Emacs?  If so, could you please apply the
> following patch and see if it solves the problem?
> 
> diff --git a/src/font.c b/src/font.c
> index a929509..bb6d18b 100644
> --- a/src/font.c
> +++ b/src/font.c
> @@ -2777,21 +2777,22 @@ font_list_entities (struct frame *f, Lisp_Object spec)
>  	  val = XCDR (val);
>  	else
>  	  {
> -	    val = driver_list->driver->list (f, scratch_font_spec);
> -	    if (!NILP (val))
> -	      {
> -		Lisp_Object copy = copy_font_spec (scratch_font_spec);
> +	    Lisp_Object copy;
>  
> -		val = Fvconcat (1, &val);
> -		ASET (copy, FONT_TYPE_INDEX, driver_list->driver->type);
> -		XSETCDR (cache, Fcons (Fcons (copy, val), XCDR (cache)));
> -	      }
> +	    val = driver_list->driver->list (f, scratch_font_spec);
> +	    if (NILP (val))
> +	      val = zero_vector;
> +	    else
> +	      val = Fvconcat (1, &val);
> +	    copy = copy_font_spec (scratch_font_spec);
> +	    ASET (copy, FONT_TYPE_INDEX, driver_list->driver->type);
> +	    XSETCDR (cache, Fcons (Fcons (copy, val), XCDR (cache)));
>  	  }
> -	if (VECTORP (val) && ASIZE (val) > 0
> +	if (ASIZE (val) > 0
>  	    && (need_filtering
>  		|| ! NILP (Vface_ignored_fonts)))
>  	  val = font_delete_unmatched (val, need_filtering ? spec : Qnil, size);
> -	if (VECTORP (val) && ASIZE (val) > 0)
> +	if (ASIZE (val) > 0)
>  	  list = Fcons (val, list);
>        }
>  
> 
[BAD-patched-buffer-set-face-profile (text/plain, attachment)]
[BAD-patched-inhibit-cache-buffer-set-face-profile (text/plain, attachment)]
[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26402; Package emacs. (Sun, 09 Apr 2017 05:45:01 GMT) Full text and rfc822 format available.

Message #23 received at 26402 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Gennady Uraltsev <gennady.uraltsev <at> gmail.com>
Cc: 26402 <at> debbugs.gnu.org
Subject: Re: bug#26402: 25.2; Font rendering extremely slow on any non-default
 font
Date: Sun, 09 Apr 2017 08:44:55 +0300
> Cc: 26402 <at> debbugs.gnu.org
> From: Gennady Uraltsev <gennady.uraltsev <at> gmail.com>
> Date: Sun, 9 Apr 2017 00:33:23 +0200
> 
> I recompiled from latest git of today so emacs decalres version 26.0.50
> I tried recompiling without your patch and also with your patch. No
> apparent improvement
> 
> I tried running both (text-scale-adjust INC) and buffer-set-face
> both with and without (setq inhibit-compacting-font-caches t)

Then I think this is a problem we never saw before.  Unfortunately,
since I'm unable to reproduce this on my machine, I cannot debug it
further.  One last idea I have is to upgrade all the relevant
libraries to their latest versions.

> The profiler profiles are attached.

The profiles clearly tell the problem is related to font metrics, but
they don't tell what exactly causes the slow-down or why.  Sorry.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26402; Package emacs. (Sun, 09 Apr 2017 09:46:02 GMT) Full text and rfc822 format available.

Message #26 received at 26402 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: gennady.uraltsev <at> gmail.com
Cc: 26402 <at> debbugs.gnu.org
Subject: Re: bug#26402: 25.2;
 Font rendering extremely slow on any non-default font
Date: Sun, 09 Apr 2017 12:45:54 +0300
> Date: Sun, 09 Apr 2017 08:44:55 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> Cc: 26402 <at> debbugs.gnu.org
> 
> > The profiler profiles are attached.
> 
> The profiles clearly tell the problem is related to font metrics, but
> they don't tell what exactly causes the slow-down or why.  Sorry.

How proficient are you with using GDB?  If I ask you to step through a
certain Emacs function and tell which of its parts is the slow one,
can you do that?  I can give more detailed instructions if needed.

TIA




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26402; Package emacs. (Sun, 09 Apr 2017 11:08:02 GMT) Full text and rfc822 format available.

Message #29 received at 26402 <at> debbugs.gnu.org (full text, mbox):

From: Gennady Uraltsev <gennady.uraltsev <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 26402 <at> debbugs.gnu.org
Subject: Re: bug#26402: 25.2; Font rendering extremely slow on any non-default
 font
Date: Sun, 9 Apr 2017 13:07:03 +0200
[Message part 1 (text/plain, inline)]
Dear Eli,

1) I must admit that I am not very familiar with GDB. I have done some
programming so I am familiar with the basic concepts but not the tool.
If you give me an outline of what to do I can try to do it (I do not
mean step by step instructions, I guess I can figure something out and
if I really can't I could ask for clarifications).

2) Currently this is what I am doing. I have some virtual machines of
otherdistributions (vanilla installations) that I use to test for bugs
(cross-check).

I see that on kubuntu 16.10 with emacs 24.5.1 and with emacs25.1.2 the
problem does not appear: everything works smoothly.


3) Just a question: is there a way to ask emacs to dump the info about
the versions of all the libraries it uses?


Let me know what to do.

Thanks!

Gena




On 09/04/17 11:45, Eli Zaretskii wrote:
> > Date: Sun, 09 Apr 2017 08:44:55 +0300
> > From: Eli Zaretskii <eliz <at> gnu.org>
> > Cc: 26402 <at> debbugs.gnu.org
> >
> >> The profiler profiles are attached.
> >
> > The profiles clearly tell the problem is related to font metrics, but
> > they don't tell what exactly causes the slow-down or why.  Sorry.
>
> How proficient are you with using GDB?  If I ask you to step through a
> certain Emacs function and tell which of its parts is the slow one,
> can you do that?  I can give more detailed instructions if needed.
>
> TIA
>


[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26402; Package emacs. (Sun, 09 Apr 2017 12:00:03 GMT) Full text and rfc822 format available.

Message #32 received at 26402 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Gennady Uraltsev <gennady.uraltsev <at> gmail.com>
Cc: 26402 <at> debbugs.gnu.org
Subject: Re: bug#26402: 25.2; Font rendering extremely slow on any non-default
 font
Date: Sun, 09 Apr 2017 14:59:16 +0300
> From: Gennady Uraltsev <gennady.uraltsev <at> gmail.com>
> Cc: 26402 <at> debbugs.gnu.org
> Date: Sun, 9 Apr 2017 13:07:03 +0200
> 
> 1) I must admit that I am not very familiar with GDB. I have done some
> programming so I am familiar with the basic concepts but not the tool.
> If you give me an outline of what to do I can try to do it (I do not
> mean step by step instructions, I guess I can figure something out and
> if I really can't I could ask for clarifications).

Thanks.

The function we are interested in is font-info, or Ffont_info on the C
level.  Its code is in the file font.c around line 5100.  It calls
various other functions, like fs_query_fontset and font_open_by_name.
I'd like to know which one of them takes most of the time, then drill
down into that function and find out which of its subroutines takes
most of the time, etc.  One way of doing that is step through the code
and find the line whose execution takes a perceptible time.

Alternatively, you could use the 'perf' utility available on GNU/Linux
systems, to profile the code of Ffont_info and its subroutines and
find out which one takes most of the time.

> I see that on kubuntu 16.10 with emacs 24.5.1 and with emacs25.1.2 the
> problem does not appear: everything works smoothly.

Maybe the fonts available on those systems are different?

> 3) Just a question: is there a way to ask emacs to dump the info about
> the versions of all the libraries it uses?

Yes, the 'ldd' command is your friend.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26402; Package emacs. (Sun, 17 Nov 2019 07:48:01 GMT) Full text and rfc822 format available.

Message #35 received at 26402 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 26402 <at> debbugs.gnu.org, Gennady Uraltsev <gennady.uraltsev <at> gmail.com>
Subject: Re: bug#26402: 25.2; Font rendering extremely slow on any
 non-default font
Date: Sun, 17 Nov 2019 08:47:36 +0100
Eli Zaretskii <eliz <at> gnu.org> writes:

> The function we are interested in is font-info, or Ffont_info on the C
> level.  Its code is in the file font.c around line 5100.  It calls
> various other functions, like fs_query_fontset and font_open_by_name.
> I'd like to know which one of them takes most of the time, then drill
> down into that function and find out which of its subroutines takes
> most of the time, etc.  One way of doing that is step through the code
> and find the line whose execution takes a perceptible time.

This was two years ago, and there was no followup.  I'm not able to
reproduce the problem here, and the font machinery in Emacs has changed
substantially in Emacs 27, so I'm closing this bug report.

If this is still a problem, please reopen.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 26402 <at> debbugs.gnu.org and Gennady Uraltsev <gennady.uraltsev <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 17 Nov 2019 07:48:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 15 Dec 2019 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 105 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.