Subject: bug#32159: 26.1; inhibit-compacting-font-caches does not fix all fonts lagging issue

From: Drew Adams <[email-masked]>
Date: Sun, 15 Jul 2018 09:50:03 -0700 (PDT)

> > Other editor does not have the similar issue.
> 
> AFAIK, no other editor supports such a large variety of fonts.

I'll probably get jumped on for chiming in here
ignorantly, but...

It's great to support a large variety of fonts.  But
if a user has lots of fonts installed then it seems
that such an advantage can become a debilitating
(i.e., severe) disadvantage.  This seems like a case
of letting a search for the perfect become the enemy
of the good.

It sounds like Emacs has a do-or-die approach, here,
trying its utmost to find a font that will fit the
bill - and using all installed fonts in its search.

It seems, at least naively, like it should be
possible for a user to control this, by toning down
Emacs's overdrive and enthusiasm in this.

Not that individual users should _have_ to do that
- I don't think they should have to.  But they
should be able to do so - and easily.

Emacs had better analyze what's going on, itself, no?
Doesn't (can't) Emacs have a better understanding of
this problem than a user?  It knows what it's doing,
why, and what the result is - what the problems are.
All a user experiences is a hang/slowdown, and all
they get when they report a bug is the answer that
they likely have too many fonts installed.

If such a font search is taking "too long" (as
determined by some setting perhaps, settable by users
but with a reasonable default value for the average)
then (1) searching should stop and (2) future searches
should be curtailed earlier.

IOW, Emacs should learn when to stop hanging a user
up.  (Having Emacs do that or not should of course
be a user choice - optional.)

Are particular fonts problematic, leading to more
slowdown/hang?  Or is it just the number of fonts
installed that is the problem?  If particular fonts,
then can't Emacs itself learn not to bother with
those fonts (for a given user)?  Why must Emacs
always try _all installed fonts_ each time?

Can't Emacs learn which fonts work for which chars,
so that it doesn't keep trying a given font when
trying to display a given char, after it's already
determined previously that that font doesn't support
that char?

I'm clearly no expert on fonts or Emacs's handling
of them.  So no doubt some of what I'm writing here
makes little sense or betrays misunderstanding.
Please take this only as one naive user's plaint.
This problem is a big one, even if only for the few
(?) users who have many fonts installed.

We (users and Emacs developers) should not be
satisfied by the conclusion that Emacs is incompatible
with having many fonts installed - especially since,
as Moses said, "Other editor does not have the similar
issue."  Even with "too many" fonts installed, Emacs
should be at least as good as other editors.

My question is essentially this: It seems like you
keep saying, and being content to say, that if too
may fonts are installed then Emacs can be slow / hang.

I trust that that's a fact now.  But why should that
be a reason for concluding that nothing can be done?
That's what seems to be happening, at least: the
problem remains, and the prescription seems to be
just "Don't do that.  Don't install so many fonts."
(Or don't use Emacs, I guess.)

To me, that's not a solution.  I have no idea whether
it might be the case that _no_ solution is possible.
But it seems like hands have been thrown up, we've
given up, and "Nothing to be done" is the response.

To those users who do get this "no other editor does
this" behavior - whether you think it's great or
not-so-great that Emacs does it, this is a severe
problem.  With no facts or real understanding of the
underlying code, it seems to this user like Emacs
could/should do better.  The status quo is not good,
for at least some users.

The line is apparently that Emacs does _better_ than
other editors because it tries harder to find a font
that can display a given char.  The fact seems to be
that, at least in some cases (e.g. many fonts
installed), Emacs, in effect, does _worse_ than other
editors.  Hence Moses saying, "Other editor does not
have the similar issue."

A user (I, for example) with many fonts installed
does not suffer dead-in-the-water behavior from
other editors (in the larger sense, i.e., any
text-input, editing, or search context).  I never
see such a problem, outside Emacs.  Never.

Can we not find some way to let users choose the
Emacs full-force-try approach or an approach used
by "other editors"?

Can we not find a way for Emacs itself, by default,
to use better judgment about how far to take its
font-search zeal, so that users do not even have to
make such a choice (but still give them the choice)?

I expect that, even if you agree that that would be
desirable (which I'm not sure you do), you might
say only: "patches welcome".

To which I'd say that this problem seems to have
_started_ at a certain point (relatively) recently,
but it's been with us for a while now, and no new
font expert has stepped forward to tackle it.

I expect that you, Eli, are likely our only hope
anytime soon of addressing this problem.  I hope
you might think more about it, realizing that
"If it hurts, don't do that" is not a reasonable
solution here.

Even if a user were prepared to uninstall a bunch
of fonts - just to make Emacs happy (usable), it's
not clear (to me at least) how s?he would go about
that.

Can Emacs not analyze the problem while it searches
desperately for a font, and so be able to report
about which fonts seem the most useless, least used,
and least useful for Emacs?  That would help a user
think about which fonts s?he might try removing.
Otherwise, how to know?

And beyond putting this burden on the user, can't
such an analysis by Emacs be used by Emacs itself,
to help it try to do the right thing by default -
have it try dropping this or that font from its
search?  IOW, can't Emacs learn about the set of
fonts installed, and not blindly try each one
everytime when trying to display a given char?

Why must the only "solution" be for a user to
uninstall fonts?  Why can't Emacs be prevented
from trying to use some of the installed fonts
for its search?