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

From: Will Bush <[email-masked]>
Date: Mon, 1 Jun 2020 06:19:02 -0500

I got distracted with yak shaving other things and circled back around to
this issue. I was reinstalling NixOS on my laptop to try my hand at getting
LUKS encryption working and decided to try to replicate the issue on there.
I was able to, but that's not too surprising since the whole point of NixOS
is reproducible environments.

I decided to try reproduce it in Manjaro on my laptop from a "live CD"
burned to a usb drive. Well that attempt got thwarted by attempting to
install a rust based AUR helper which ate up all my RAM (on my old laptop)
and started swapping to my usb drive. (I was trying to get an AUR helper to
install google fonts)

So I installed virt-manager (et al) (on my main computer) and Manjaro in a
virtual machine. I built Emacs from source using `make` and `make install`
from the latest in the master branch in git://git.savannah.gnu.org/emacs.git.
Then I installed google fonts from
https://aur.archlinux.org/packages/ttf-google-fonts-git/

... and... no issue dammit.

So I got my local machine back to the state where the issues occurred.
`fc-list | rg -i google > fonts.txt` and use the power of Emacs to turn the
~1800 fonts into a list of strings I can set to `face-ignored-fonts`
variable.

I was excited to see that ignoring all 1800+ fonts fixed the perf issue. So
I binary searched through them commenting them out and narrowed it down to
one.. damn font "Adobe Blank".

And sure enough (on my local NixOS machine):

λ ~/ time emacs -Q --eval '(message "︵")' -kill
emacs -Q --eval '(message "︵")' -kill  82.35s user 0.03s system 99% cpu
1:22.56 total

λ ~/ time emacs -Q --eval "(progn (setq face-ignored-fonts '(\"Adobe
Blank\")) (message \"︵\"))" -kill
emacs -Q --eval  -kill  0.22s user 0.02s system 68% cpu 0.349 total

AHHHH!!!!

I open up Manjaro in the virtual machine and:

git clone https://github.com/adobe-fonts/adobe-blank.git
cd adobe-blank
sudo cp AdobeBlank.ttf /usr/share/fonts/
fc-cache
time emacs -Q --eval '(message "︵")' -kill

And it took 4 minutes in the virtual machine!

Turns out that https://aur.archlinux.org/packages/ttf-google-fonts-git/
didn't have Adobe Blank font.

Please try it and see if you can repro!

Also, please note that the character I have been testing with is not the
only one were this issue shows up. I have run into the issue when grep for
things using deadgrep, but I didn't spend the time to narrow down to an
exact character in those cases.

On Wed, Apr 29, 2020 at 9:31 AM Eli Zaretskii <[email-masked]> wrote:

> > From: Will Bush <[email-masked]>
> > Date: Wed, 29 Apr 2020 07:42:20 -0500
> > Cc: Robert Pluim <[email-masked]>, "Basil L. Contovounesios" <
> [email-masked]>, [email-masked],
> >       James Cloos <[email-masked]>
> >
> > Did you see my other message that I forwarded where I forgot to CC
> everyone? I
> > was able to switch between a bunch of revisions of the master branch to
> see
> > where the performance issue started, and it appears to have started with
> commit
> > (88efc736f5 Default cairo to enabled). I was hoping that would narrow it
> down.
>
> I don't think it does.
>
> And the profile you show doesn't seem to be pointing at Emacs as the
> culprit, since all the functions shown are unrelated to displaying
> characters.  So perhaps Robert is right, and some font-related
> subsystem of your OS is what takes time here.
>