help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is font fallback slow over X11/ssh?


From: Yuri Khan
Subject: Is font fallback slow over X11/ssh?
Date: Thu, 28 May 2020 19:11:12 +0700

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 via email to

[Prev in Thread] Current Thread [Next in Thread]