unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Is font fallback slow over X11/ssh?
@ 2020-05-28 12:11 Yuri Khan
  2020-05-31  8:16 ` Dmitry Alexandrov
  0 siblings, 1 reply; 7+ messages in thread
From: Yuri Khan @ 2020-05-28 12:11 UTC (permalink / raw)
  To: help-gnu-emacs

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.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-06-05 15:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-28 12:11 Is font fallback slow over X11/ssh? Yuri Khan
2020-05-31  8:16 ` 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

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).