unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Kai Ma <justksqsf@gmail.com>
Cc: jporterbugs@gmail.com, jb@jeremybryant.net, 71454@debbugs.gnu.org
Subject: bug#71454: 30.0.50; Performance issues with font selection
Date: Mon, 10 Jun 2024 14:53:36 +0300	[thread overview]
Message-ID: <867cex9fpb.fsf@gnu.org> (raw)
In-Reply-To: <F814273E-4A20-46BC-88C9-37538C4DFAB9@gmail.com> (message from Kai Ma on Mon, 10 Jun 2024 04:18:08 +0200)

severity 71454 wishlist
thanks

> Cc: Jeremy Bryant <jb@jeremybryant.net>, 71454@debbugs.gnu.org
> From: Kai Ma <justksqsf@gmail.com>
> Date: Mon, 10 Jun 2024 04:18:08 +0200
> 
> > On Jun 10, 2024, at 01:10, Jim Porter <jporterbugs@gmail.com> wrote:
> > 
> > On 6/9/2024 3:17 PM, Kai Ma wrote:
> >>> On Jun 10, 2024, at 00:10, Jeremy Bryant <jb@jeremybryant.net> wrote:
> >>> 
> >>> Would you be able to provide a self-contained series of steps starting
> >>> from emacs -Q?
> >> On my machine it is extremely easy to reproduce by simply:
> >> 1. emacs -Q
> >> 2. Switch to *scratch*
> >> 3. Copy the provided text into *scratch*
> >> 4. Emacs will freeze for 17 seconds or so, and it cannot be interrupted by C-g
> > 
> > Is this on MS-Windows, by chance? Using a different set of steps, I can reproduce this issue on MS-Windows (Emacs 29.3), but not on GNU/Linux. Here's what I did:
> > 
> >  emacs -Q
> >  C-h v comint-password-prompt-regexp RET
> 
> 
> I’m using macOS. I apologize for not adding this info to my original report.
> 
> And yes, I can also reproduce the issue with C-h v comint-password-prompt-regexp RET

AFAICT, the problematic part of comint-password-prompt-regexp is this:

  गुप्तशब्द\\|शब्दकूट\\|গুপ্তশব্দ\\|পাসওয়ার্ড\\|ਪਾਸਵਰਡ\\|પાસવર્ડ\\|ପ୍ରବେଶ ସଙ୍କେତ\\|கடவுச்சொல்\\|సంకేతపదము\\|ಗುಪ್ತಪದ\\|അടയാളവാക്ക്\\|රහස්පදය

This has nothing to do with the number of fonts installed on the
system, nor with how Emacs searches for fonts, nor even with the fonts
themselves.  On my system, all of the characters above are displayed
using the same single font.  And yet, even if I insert just a single
character of those, which causes Emacs to find and load that font,
pasting the rest of the string takes several seconds in an unoptimized
build (I expect it to take about 2 sec or less in an optimized build).

Note that if you then paste the same string over and over again, the
display is instantaneous.

My crystal ball says that the expensive part here is character
composition.  The above characters belong to scripts that require
extensive composition rules, take a look at indian.el and its complex
regexps.  Displaying those characters requires the display code to
examine all those regexps, to find the largest composable sequence,
then generate the compositions by calling into Lisp, which then calls
back into C where we call HarfBuzz to produce the font glyphs for the
compositions.  This is expensive, and so Emacs caches each composition
for further use, which explains why subsequent pastes are much faster.

IOW, this is a price we pay for the fact that we make character
compositions infinitely customizable on the Lisp level.

So far, I see no bug here.  Of course, if someone wants to work on
redesign of how Emacs handles character composition, and as part of
such a redesign will make the process much faster, that would be very
welcome.





  reply	other threads:[~2024-06-10 11:53 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-09 18:56 bug#71454: 30.0.50; Performance issues with font selection Kai Ma
2024-06-09 22:10 ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-09 22:17   ` Kai Ma
2024-06-09 22:34     ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-10  2:14       ` Kai Ma
2024-06-10 12:04         ` Eli Zaretskii
2024-06-09 23:10     ` Jim Porter
2024-06-10  2:18       ` Kai Ma
2024-06-10 11:53         ` Eli Zaretskii [this message]
2024-06-10 16:31           ` Jim Porter
2024-06-10 17:35             ` Eli Zaretskii
2024-06-10 11:55     ` Eli Zaretskii
2024-06-10 12:35       ` Kai Ma
2024-06-10 12:59         ` Eli Zaretskii
2024-06-10 16:42           ` Gerd Möllmann
2024-06-10 17:36             ` Kai Ma
2024-06-10 18:05               ` Gerd Möllmann
2024-06-10 11:58 ` Eli Zaretskii
2024-06-10 12:34   ` Kai Ma
2024-06-10 13:03     ` Eli Zaretskii

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=867cex9fpb.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=71454@debbugs.gnu.org \
    --cc=jb@jeremybryant.net \
    --cc=jporterbugs@gmail.com \
    --cc=justksqsf@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

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

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