all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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

* Re: Is font fallback slow over X11/ssh?
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Alexandrov @ 2020-05-31  8:16 UTC (permalink / raw)
  To: Yuri Khan; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 219 bytes --]

> Is font fallback slow over X11/ssh?

FWIW, yes, it is.  And thatʼs one of my reasons to prefer server-side font rendering for remote Emacs sessions.  I. e. something like:

	$ emacs --xrm='Emacs.fontBackend: x'

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

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

* Re: Is font fallback slow over X11/ssh?
  2020-05-31  8:16 ` Dmitry Alexandrov
@ 2020-05-31 13:13   ` Stefan Monnier
  2020-06-04 17:24     ` Dmitry Alexandrov
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2020-05-31 13:13 UTC (permalink / raw)
  To: help-gnu-emacs

>> Is font fallback slow over X11/ssh?
> FWIW, yes, it is.  And thatʼs one of my reasons to prefer server-side font
> rendering for remote Emacs sessions.  I. e. something like:
> 	$ emacs --xrm='Emacs.fontBackend: x'

Interesting.  Do you have some explanation for why you find it more
useful for remote sessions?  Have you tried to *disable* the `x`
fontBackend instead?


        Stefan




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

* Re: Is font fallback slow over X11/ssh?
  2020-05-31 13:13   ` Stefan Monnier
@ 2020-06-04 17:24     ` Dmitry Alexandrov
  2020-06-04 21:01       ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Alexandrov @ 2020-06-04 17:24 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs, yuri.v.khan

[-- Attachment #1: Type: text/plain, Size: 811 bytes --]

Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>> Is font fallback slow over X11/ssh?
>> FWIW, yes, it is.  And thatʼs one of my reasons to prefer server-side font rendering for remote Emacs sessions.  I. e. something like:
>> 	$ emacs --xrm='Emacs.fontBackend: x'
>
> Interesting.  Do you have some explanation for why you find it more useful for remote sessions?

No, in the sense that @yuri.v.khan@gmail.comʼs one is more thorough than mine.

> Have you tried to *disable* the `x` fontBackend instead?

Yes, in fact due to bug#25216 this is my normal setup.

	! https://bugs.gnu.org/25216
	Emacs.fontBackend: xft,ftcrhb

Why _it_ could help, I wonder now?


P. S. Hint: If youʼd like to get a prompter reply, it may be useful to actually address a person while addressing him.  ;-)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

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

* Re: Is font fallback slow over X11/ssh?
  2020-06-04 17:24     ` Dmitry Alexandrov
@ 2020-06-04 21:01       ` Stefan Monnier
  2020-06-05 10:32         ` Dmitry Alexandrov
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2020-06-04 21:01 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: Dmitry Alexandrov

>>>> Is font fallback slow over X11/ssh?
>>> FWIW, yes, it is.  And thatʼs one of my reasons to prefer
>>> server-side font rendering for remote Emacs sessions.
>>> I. e. something like:
>>> 	$ emacs --xrm='Emacs.fontBackend: x'
>> Interesting.  Do you have some explanation for why you find it more useful for remote sessions?
> No, in the sense that @yuri.v.khan@gmail.comʼs one is more thorough than mine.

My question was based on my foggy memory that back when client-side
fonts (xft) were introduced to the wonderful X11 world, there was some
article that came out explaining that while it requires sending the
bitmap of characters to the Xserver, it ends up being faster in remote
connections because the amount of data to send is not really larger than
the amount of data fetched from the Xserver for server-side fonts
(mostly in the form of the font-metrics) and suffers much less from
latency because it's "send-only" instead RPC.

>> Have you tried to *disable* the `x` fontBackend instead?
> Yes, in fact due to bug#25216 this is my normal setup.
>
> 	! https://bugs.gnu.org/25216
> 	Emacs.fontBackend: xft,ftcrhb
>
> Why _it_ could help, I wonder now?

The idea was that it would avoid paying the cost of the `x` backend.


        Stefan




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

* Re: Is font fallback slow over X11/ssh?
  2020-06-04 21:01       ` Stefan Monnier
@ 2020-06-05 10:32         ` Dmitry Alexandrov
  2020-06-05 15:22           ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Alexandrov @ 2020-06-05 10:32 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 535 bytes --]

Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>> Have you tried to *disable* the `x` fontBackend instead?
>> Yes, in fact due to bug#25216 this is my normal setup.
>> Why _it_ could help, I wonder now?
>
> The idea was that it would avoid paying the cost of the `x` backend.

So, it turns out than in practice this cost is much lower than costs of other backends.  And itʼs not unexpected in the light of hypothesis above: typically, there are just much less fonts available via ‘x’ than via ‘xft’ / ‘ftcrhb’.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

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

* Re: Is font fallback slow over X11/ssh?
  2020-06-05 10:32         ` Dmitry Alexandrov
@ 2020-06-05 15:22           ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2020-06-05 15:22 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: Dmitry Alexandrov

> And itʼs not unexpected in the light of hypothesis above: typically,
> there are just much less fonts available via ‘x’ than via ‘xft’ /
> ‘ftcrhb’.

Oh, right, that's the part I had overlooked, thanks,


        Stefan




^ 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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.