Subject: Fwd: bug#40733: 28.0.50; Emacs locks up on paste (yank) of unicode characters

From: Will Bush <[email-masked]>
Date: Sat, 25 Apr 2020 08:34:05 -0500

I forgot to CC everyone.

---------- Forwarded message ---------
From: Will Bush <[email-masked]>
Date: Sat, Apr 25, 2020 at 8:30 AM
Subject: Re: bug#40733: 28.0.50; Emacs locks up on paste (yank) of unicode
characters
To: Robert Pluim <[email-masked]>

Robert> ...we implicitly do '--with-cairo' now.

Will> Is that since 27.0.50?

Think I just answered my own question the hard way.

I was able to narrow the performance issue to starting after rev
`6100f9a19e9d8d8e688ad8bbec2233bd6782cbde` and before or at
`a75047634697acbc37a9ecd58cc5e7ea9d89d91f` in the master branch in Emacs
repository.

Which corresponds to these commits:

06caa3b7e5 | * | Refactor Tramp async process code
88efc736f5 | * | Default cairo to enabled
4fc0bc9678 | * | Update from gnulib
0abda558bc | * | Port configure.ac to future Gnulib
6100f9a19e | * | * src/pdumper.c (dump_vectorlike): Unbreak build after
724af7671590c

Lol "Default cairo to enabled" really stands out there. It's probably safe
to
assume that's what it is.

Following goes into extraneous detail showing how I verified it's between
those
two revisions:

λ ~/system/nixos/ emacs/revamp* niv update emacs-overlay -a
rev=0feda8b31b52f3ea008555dfe79dba3989d3e585
Update emacs-overlay
  Reading sources file
Done: Update emacs-overlay
λ ~/system/nixos/ emacs/revamp* home-manager switch
... home manager spam goes here
λ ~/system/nixos/ emacs/revamp* time emacs -Q --eval '(message "︵")' -kill
emacs -Q --eval '(message "︵")' -kill  0.42s user 0.02s system 64% cpu
0.690 total
λ ~/system/nixos/ emacs/revamp* time emacs -Q --eval '(message "︵")' -kill
emacs -Q --eval '(message "︵")' -kill  0.43s user 0.02s system 94% cpu
0.472 total
λ ~/system/nixos/ emacs/revamp* niv update emacs-overlay -a
rev=a75047634697acbc37a9ecd58cc5e7ea9d89d91f
Update emacs-overlay
  Reading sources file
Done: Update emacs-overlay
λ ~/system/nixos/ emacs/revamp* home-manager switch
... more home manager spam
λ ~/system/nixos/ emacs/revamp* time emacs -Q --eval '(message "︵")' -kill
emacs -Q --eval '(message "︵")' -kill  80.73s user 0.02s system 99% cpu
1:20.97 total
λ ~/system/nixos/ emacs/revamp*

The `niv update emacs-overlay -a
rev=a75047634697acbc37a9ecd58cc5e7ea9d89d91f`
command is using a tool called niv to update emacs-overlay to a pinned
version.
The rev in the diff below is for the Emacs repository.

*# perf issue:*

a75047634697acbc37a9ecd58cc5e7ea9d89d91f
Author:     emacs-overlay <emacs-overlay@nix-community>
AuthorDate: Tue Jan 14 12:10:25 2020 +0000
Commit:     emacs-overlay <emacs-overlay@nix-community>
CommitDate: Tue Jan 14 12:10:25 2020 +0000

Parent:     9351772 Updated repos/melpa
Contained:  master

Updated repos/emacs

modified   repos/emacs/emacs.json
@@ -1 +1 @@
-{"rev": "4fc0bc96787252b1b3e14a7f747ef556273b5979", "sha256":
"0syw4xcbps6i62fa7l88zyvyc3kiggx2kpa2n41p8y2pl01vdqqs", "version":
"20200114.0"}
+{"rev": "06caa3b7e5e9fe91b6918f8567adbd5501d6dbdd", "sha256":
"0kzk30660xky0zj7v5sr9a49pnnz609jda4s8x86pjk91x1wrv2i", "version":
"20200114.0"}

*# no perf issue:*

0feda8b31b52f3ea008555dfe79dba3989d3e585
Author:     emacs-overlay <emacs-overlay@nix-community>
AuthorDate: Mon Jan 13 00:10:30 2020 +0000
Commit:     emacs-overlay <emacs-overlay@nix-community>
CommitDate: Mon Jan 13 00:10:30 2020 +0000

Parent:     e38dc3b Updated repos/melpa
Contained:  master

Updated repos/emacs

modified   repos/emacs/emacs.json
@@ -1 +1 @@
-{"rev": "41d9d51cf5ac5b76c09802388e1691cf489d9d9d", "sha256":
"1vy1fcw2m7lbw8wcwmp04zwkqra835vdbxbgnms3wgrwviqm14zd", "version":
"20200111.0"}
+{"rev": "6100f9a19e9d8d8e688ad8bbec2233bd6782cbde", "sha256":
"01fvxplljwnz11sizlfpl219dvrg7yf790zmr69wvkn6wlgxif76", "version":
"20200112.0"}

On Sat, Apr 25, 2020 at 5:34 AM Will Bush <[email-masked]> wrote:

> Robert> Which font specifically does emacs end up using for that character?
> Robert> Emacs ends up using 'Noto Sans CJK KR' for me here.
>
> When google fonts is removed?
>
> This is what `C-u C-x =` says:
>
> ftcrhb:-PfEd-Unifont-normal-normal-normal-*-15-*-*-*-d-0-iso10646-1
> (#xDD38ftcrhb:-PfEd-Unifont-normal-normal-normal-*-15-*-*-*-d-0-iso10646-1
> (#xDD38)
>
> Note on the above: For the hell of it, I tried installing `noto-fonts`
> font pack
> from nixpkgs and it didn't make a difference. Then again, `fc-list
> --verbose |
> rg "Noto Sans CJK" -i` produced no results so that specific font probably
> isn't
> in that font pack.
>
> When google fonts are installed:
>
> ftcrhb:-GNU-Unifont-normal-normal-normal-Sans-Serif-16-*-*-*-c-80-iso10646-1
> (#xDD36)
>
> Robert> BTW, if you want to ignore that font, you can set
> Robert> 'face-ignored-fonts' to match it, and you won't have to uninstall
> it.
>
> Thanks, I didn't know that! Maybe I can use that to narrow down to the
> specific
> font that's causing problems because adding `google-fonts` adds 2905 fonts
> for
> me, and many I would like to have.
>
> Robert> I donʼt think thereʼs much point in that: emacs-26 uses Xft for
> font
> Robert> handling, emacs-27 uses Cairo+Harfbuzz[1]; theyʼre fundamentally
> doing
> Robert> very different things, so I donʼt think this is caused by a single
> Robert> identifiable change.
>
> I'm not trying to prove you wrong or anything. It's just easy for me to try
> different versions because I'm using
> (https://github.com/nix-community/emacs-overlay). However, I tried Emacs
> 27.0.50
> and it's behaving exactly the same as Emacs 26. I glanced at the
> `report-emacs-bug` output and the build inputs look the same. I can
> include it
> if desired.
>
> λ ~/ time emacs -Q --eval '(message "hi")' -kill
> emacs -Q --eval '(message "hi")' -kill  0.18s user 0.02s system 67% cpu
> 0.303 total
> λ ~/ time emacs -Q --eval '(message "︵")' -kill
> emacs -Q --eval '(message "︵")' -kill  0.44s user 0.03s system 95% cpu
> 0.494 total
> λ ~/ emacs --version
> GNU Emacs 27.0.50
>
> Robert> ...we implicitly do '--with-cairo' now.
>
> Is that since 27.0.50?
>
> Were either Cairo+Harfbuzz libraries updated since 27.0.50 (perhaps a
> regression
> in those libraries)? I'll follow up with an update later after testing
> more versions.
>
> Robert> Although you can still build it with Xft if you want, but I
> Robert> wouldnʼt recommend that, since it will crash once you start
> Robert> processing Emojis and other 'interesting' Unicode characters.
>
> Just to verity I understand. Building with Xft is what `--with-xft` is
> doing in
> the following from my initial email?
>
> Configured using:
>  'configure
>  --prefix=/nix/store/5v0fp6vikajaqc2v0ppkm51hfc054mnm-emacs-git-20190910.0
>  --disable-build-details --with-modules --with-x-toolkit=gtk3 --with-xft
>  CFLAGS=-DMAC_OS_X_VERSION_MAX_ALLOWED=101200'
>
> Eli> I'm not sure I understand: you are saying that slow, but correct
> Eli> display is _worse_ than displaying a white space instead of the
> Eli> correct glyph, i.e. producing incorrect display?  To me, it sounds
> Eli> like Emacs 27+ actually _improves_ things in this case.
>
> Let me quantify the performance because I've been ambiguous about it so
> far:
>
> λ ~/ time emacs -Q --eval '(message "hi")' -kill
> emacs -Q --eval '(message "hi")' -kill  0.19s user 0.02s system 55% cpu
> 0.371 total
> λ ~/ time emacs -Q --eval '(message "︵")' -kill
> emacs -Q --eval '(message "︵")' -kill  81.64s user 0.03s system 99% cpu
> 1:21.91 total
>
> It takes ~81 seconds to do something while locking up the UI. That's
> personally
> beyond my threshold for killing the process.
>
>
> On Wed, Apr 22, 2020 at 2:35 AM Robert Pluim <[email-masked]> wrote:
>
>> >>>>> On Tue, 21 Apr 2020 15:35:23 -0400, James Cloos <[email-masked]>
>> said:
>>
>> >>>>> "RP" == Robert Pluim <[email-masked]> writes:
>>     RP> Footnotes:
>>     RP> [1]  Although you can still build it with Xft if you want, but I
>>     RP> wouldnʼt recommend that, since it will crash once you start
>>     RP> processing Emojis and other 'interesting' Unicode characters.
>>
>>     James> note that master will also crash when using cr+hb on some code
>> points.
>>
>>     James> such as some private use characters.
>>
>> Examples? Eli fixed one such case with Bug#39892, but if there are
>> more we should fix them (please open a separate bug report for that).
>>
>> Robert
>>
>