unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Yuri Khan <yuri.v.khan@gmail.com>
To: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Is font fallback slow over X11/ssh?
Date: Thu, 28 May 2020 19:11:12 +0700	[thread overview]
Message-ID: <CAP_d_8XSyQoPkSSrN5JD1fD=dwto-hv3EMBfe+Rz1HhUm0=BEw@mail.gmail.com> (raw)

Hello,

yesterday/today I got to investigate an issue that I perceived as
“slow Emacs startup”. I’d like to share my findings.

The setup goes like this:

* Home machine: Ubuntu 20.04, X.org, ‘fc-list | wc -l’ says 2698.
* Office machine: Ubuntu 18.04, X.org, Emacs 26.3/GTK+3, some
customizations involving minor mode lighter changes replacing words
with Unicode characters.

I run Emacs on the office machine over ssh with X11 forwarding, so the
GUI is displayed on my home machine.

Every time I started Emacs this way, it took several minutes to start
up and become usable. I had thought it was due to the complexity of my
init.el. However, when I added a (message "%s" (emacs-init-time)) to
the end of it, I found out that it gets echoed fairly early, in about
30s from the process start.

Bisecting the set of files loaded from my init.el led me to the one
that enables undo-tree. When I disabled its loading, Emacs became
responsive in about 30s. When I enabled it again, it took ~3min to
start.

I then did a ‘profile-start’ and loaded it manually. ‘profile-report’
said… most of the time was spent in redisplay.

Now, as I said, I change some modes’ lighters to symbols. In
particular, for undo-tree, I use ⮌🌲 (U+2B8C Anticlockwise
triangle-headed right u-shaped arrow, U+1F332 Evergreen tree).

I imagine what happens is this:

* Emacs starts up.
* undo-tree mode activates.
* Emacs finishes starting up and is ready to paint the screen.
* Emacs: Okay, let’s draw that lighter. Hey X, does the Cousine font
have ⮌ and 🌲 glyphs?
* X: No.
* Now Emacs starts enumerating the fonts, looking for one that does
have at least one of those glyphs. If I’m fortunate, it finds one
after a few tries. If not, it enumerates hundreds of fonts. I can
imagine each attempt taking a network round trip, and possibly some
data transfer.

I believe I managed to fix the issue by moving the ‘unicode-fonts’
package configuration higher in the init sequence and telling it about
several Unicode blocks that I had neglected earlier. Now, Emacs finds
the necessary fonts much faster.


Is my understanding of the font fallback mechanics correct?

Could I customize it to not ever do that? If my default font does not
have a glyph for a code point, and none of the fonts in the fontset
have glyphs for that code point, don’t go scanning all my fonts, just
display a tofu and be done with it.



             reply	other threads:[~2020-05-28 12:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-28 12:11 Yuri Khan [this message]
2020-05-31  8:16 ` Is font fallback slow over X11/ssh? Dmitry Alexandrov
2020-05-31 13:13   ` Stefan Monnier
2020-06-04 17:24     ` Dmitry Alexandrov
2020-06-04 21:01       ` Stefan Monnier
2020-06-05 10:32         ` Dmitry Alexandrov
2020-06-05 15:22           ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAP_d_8XSyQoPkSSrN5JD1fD=dwto-hv3EMBfe+Rz1HhUm0=BEw@mail.gmail.com' \
    --to=yuri.v.khan@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).