all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Clément Pit--Claudel" <clement.pitclaudel@live.com>
Cc: 21028@debbugs.gnu.org
Subject: bug#21028: Performance regression in revision af1a69f4d17a482c359d98c00ef86fac835b5fac (Apr 2014).
Date: Tue, 14 Mar 2017 17:45:30 +0200	[thread overview]
Message-ID: <83k27rc15x.fsf@gnu.org> (raw)
In-Reply-To: <16f9db27-dd0f-ddaf-2f34-45b9fd4e69c6@live.com> (message from Clément Pit--Claudel on Mon, 13 Mar 2017 15:04:24 -0400)

> Cc: 21028@debbugs.gnu.org
> From: Clément Pit--Claudel <clement.pitclaudel@live.com>
> Date: Mon, 13 Mar 2017 15:04:24 -0400
> 
> # Stock 25.1
> $ time 25.1/src/emacs -Q --eval "(progn (set-fontset-font \"fontset-startup\" 'unicode \"Noto Sans\" nil) (set-fontset-font \"fontset-startup\" 'unicode \"Symbola\" nil 'append) (dotimes (_ 5000) (insert (make-string 20 8658) \"\n\")) (goto-char (point-min)) (sit-for 0) (condition-case nil (while t (scroll-up) (sit-for 0)) (error nil)) (run-with-idle-timer 0 nil #'kill-emacs))"
> real	1m4.705s
> user	0m18.296s
> sys	0m18.444s

I checked: all the fonts you use as the default -- Noto Sans, Fira
Sans, Ubuntu Mono -- all of them basically support only Latin, Greek,
and Cyrillic blocks, and very little else.  By contrast, the above
fontset specification claims that they support the entire Unicode
range of characters, which causes Emacs waste cycles trying to use
these fonts for display of characters they don't support.

In addition, the font-spec doesn't specify the registry of the fonts,
leaving that to the default, which IME is inadequate.  So please try
the following, and see if you get any significant speedup:

  time emacs -Q --eval "(progn (set-fontset-font \"fontset-default\" 'latin '(\"Noto Sans\" . \"iso10646-1\") nil) (set-fontset-font \"fontset-default\" 'unicode '(\"Symbola\" . \"iso10646-1\") nil 'append) (dotimes (_ 5000) (insert (make-string 20 8658) \"\n\")) (goto-char (point-min)) (sit-for 0) (condition-case nil (while t (scroll-up) (sit-for 0)) (error nil)) (run-with-idle-timer 0 nil #'kill-emacs)))"

I get a 4-fold speedup with this, it would be interesting to know
whether you see any improvements.

Other than that, I'm sorry to say that I couldn't reproduce any of the
slowdowns you mention in this bug report and in the referenced issues.
In each of the recipes I tried, the slowdown disappears either if I
set inhibit-compacting-font-caches (which you said doesn't affect your
use cases) or if I define the fontset correctly, like specify a
registry for a font or the scripts it really supports.  It's possible
that these factors somehow have a much more significant effect on your
system, I don't know why.  Perhaps you have an awful lot of fonts
installed?  What does the following yield when evaluated:

  (length (x-list-fonts "-*-*-*-r-*-*-*-*-*-*-*-*-iso10646-1"))

(I get 1398.)

Allow me a few comments on your real-life setup, they could be
relevant even if they don't resolve the slow display with stock Emacs:

  (defun my-configure-one-fontset (fontset &optional size)
    "Add fallbacks to FONTSET with SIZE."
    (let* ((size (when size `(:size ,(/ size 10.0))))
	   (base-spec (apply #'font-spec :name ~/main-font size))
	   (emoji-spec (apply #'font-spec :name (format "Segoe UI Emoji monospacified for %s" ~/main-font) size))
	   (symbol-spec (apply #'font-spec :name (format "XITS Math monospacified for %s" ~/main-font) size))
	   (fallback-spec (apply #'font-spec :name (format "Symbola monospacified for %s" ~/main-font) size))
	   (cjk-spec (apply #'font-spec :name "WenQuanYi Micro Hei Mono" size)))

All of the above specs lack a proper :registry value, which should be
'iso10646-1.

      (set-fontset-font fontset 'unicode base-spec nil)

This should only specify 'latin, 'greek, and 'cyrillic (one such line
for each of them), as 'unicode is a blatant lie.

      (set-fontset-font fontset 'unicode emoji-spec nil 'append)

It is better o have a definitive list of codepoint ranges here, since
again 'unicode is not what you want.  Once you have the ranges, you
can use 'prepend, which will speed up things a bit more, because Emacs
won't need to go through all the fonts you don't want to see.

      (set-fontset-font fontset 'unicode symbol-spec nil 'append)

Likewise here.

      (set-fontset-font fontset 'unicode fallback-spec nil 'append)

This you shouldn't need doing, as Symbola is already in the default
fontset, and set up according to the characters where it shines.

      (set-fontset-font fontset (cons ?😱 ?😱) "Symbola" nil 'prepend)
      (set-fontset-font fontset (cons #x2009 #x2009) "Symbola" nil 'prepend) ;; Thin space

Likewise.

      (dolist (cjk-block '((#x3000 . #x303F)
			   (#x3040 . #x309F)
			   (#x30A0 . #x30FF)
			   (#x3400 . #x4DFF)
			   (#x4E00 . #x9FFF)
			   (#xF900 . #xFAFF)
			   (#x20000 . #x2A6DF)
			   (#x2A700 . #x2B73F)
			   (#x2B740 . #x2B81F)
			   (#x2B820 . #x2CEAF)
			   (#x2F800 . #x2FA1F)))
  (set-fontset-font fontset cjk-block cjk-spec nil 'append))))

This should use 'prepend, not 'append, IMO.

One more comment: any reasons why you set this up for all the
fontsets, not just for fontset-default?  AFAIU, doing these changes in
all of the fonts might slow down things even more, for no good reason,
because fontset-default is the fallback for all the other fontsets
anyway, so anything you set up in it will be in effect for any other
fontset.

> I'm not alone.  At least one other person posted to this bug list (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21028#74) and confirmed that the patch fixed their problem.

That user's fontset setup makes even less sense to me than yours.  I
will respond to that in a separate message.

> The problem gets regularly mentioned elsewhere (when I opened this bug I linked to https://github.com/purcell/emacs.d/issues/273 "when I first try to input some chinese characters, it's very slow to moving [...] especially use C-n, C-p, emacs will hang for about 1~2 seconds.";

The slowdown in that example disappears for me once I set
inhibit-compacting-font-caches non-nil.  So the factors at work in
that example on my system are somehow different from the factors on
your system (unless you will tell that inhibit-compacting-font-caches
solves the problem for you as well in that case).

> a more recent example is at https://sympa.inria.fr/sympa/arc/coq-club/2017-03/msg00050.html "Appending to the 'unicode list makes emacs unbearably slow.").

This is from the same user who wrote here yesterday.  I comment on his
setup in a separate message.

> Additionally, as the maintainer of company-coq, I've had multiple people tell me that it was just too slow to use, only to realize that turning off prettify-symbols-mode was enough to make everything snappy again for them.

Can you ask some of those people to show their fontset setup?  I'd
like to know how different they are from your setup.

Btw, I'm still trying to understand the significance of the proposed
patch, although it's hard without a clear-cut test case.

Thanks.





  parent reply	other threads:[~2017-03-14 15:45 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-10 10:34 bug#21028: Performance regression in revision af1a69f4d17a482c359d98c00ef86fac835b5fac (Apr 2014) Clément Pit--Claudel
2015-07-10 12:30 ` Eli Zaretskii
2015-07-10 16:02   ` Clément Pit--Claudel
2015-07-10 12:41 ` Eli Zaretskii
2015-07-10 16:55   ` Clément Pit--Claudel
2015-07-15 12:32     ` Dmitry Antipov
2015-07-18 10:24       ` Clément Pit--Claudel
2015-07-18 11:16         ` Clément Pit--Claudel
2015-07-18 11:26           ` Eli Zaretskii
2015-07-18 20:08             ` Clément Pit--Claudel
2016-03-03  6:12       ` Clément Pit--Claudel
2016-03-03  6:42         ` Clément Pit--Claudel
2016-03-03  7:08           ` Clément Pit--Claudel
2016-03-03  7:33             ` Clément Pit--Claudel
2016-03-03 17:10               ` Glenn Morris
2016-03-03 17:28                 ` Clément Pit--Claudel
2016-03-03 20:27               ` Eli Zaretskii
2016-07-20 21:26                 ` Clément Pit--Claudel
2016-07-21 14:21                   ` Eli Zaretskii
2016-07-21 14:33                     ` Clément Pit--Claudel
2016-07-23 20:50                     ` Clément Pit--Claudel
2016-10-04 22:17                       ` Clément Pit--Claudel
2016-10-26 17:15                         ` Clément Pit--Claudel
2016-10-27 14:38                           ` Eli Zaretskii
2016-10-27 15:29                             ` Clément Pit--Claudel
2016-10-27 15:55                               ` Eli Zaretskii
2016-10-28 14:23                                 ` Clément Pit--Claudel
2016-10-28 14:33                                   ` Eli Zaretskii
2016-11-18  8:55                                     ` Eli Zaretskii
2016-12-18 17:33                                     ` Clément Pit--Claudel
2016-12-18 17:37                                       ` Eli Zaretskii
2016-12-18 18:04                                         ` Clément Pit--Claudel
2016-12-18 19:52                                           ` Eli Zaretskii
2016-12-18 20:44                                             ` Clément Pit--Claudel
2016-12-19 15:50                                               ` Eli Zaretskii
2016-12-19 16:25                                                 ` Clément Pit--Claudel
2016-12-19 16:39                                                   ` Eli Zaretskii
2016-12-19 16:55                                                     ` Clément Pit--Claudel
2016-12-19 16:58                                                       ` Eli Zaretskii
2016-12-19 17:13                                                         ` Clément Pit--Claudel
2016-12-22 16:25                                                           ` Eli Zaretskii
2016-12-22 16:49                                                             ` Clément Pit--Claudel
2016-12-22 18:04                                                               ` Eli Zaretskii
2016-12-22 19:08                                                                 ` Clément Pit--Claudel
2017-02-10  4:45                                                                   ` Clément Pit--Claudel
2017-03-12 11:38                                                                     ` Clément Pit--Claudel
2017-03-12 15:49                                                                       ` Eli Zaretskii
2017-03-12 17:24                                                                         ` Clément Pit--Claudel
2017-03-12 17:48                                                                           ` Eli Zaretskii
2017-03-12 19:19                                                                             ` Clément Pit--Claudel
2017-03-13 15:46                                                                               ` Eli Zaretskii
2017-03-13 16:36                                                                                 ` Clément Pit--Claudel
2017-03-13 17:22                                                                                   ` Eli Zaretskii
2017-03-13 19:04                                                                                     ` Clément Pit--Claudel
2017-03-13 20:53                                                                                       ` Eli Zaretskii
2017-03-14 19:45                                                                                         ` Clément Pit--Claudel
2017-03-15 15:37                                                                                           ` Eli Zaretskii
2017-03-14 15:45                                                                                       ` Eli Zaretskii [this message]
2017-03-14 19:35                                                                                         ` Clément Pit--Claudel
2017-03-15 15:36                                                                                           ` Eli Zaretskii
2017-03-15 20:46                                                                                             ` Clément Pit--Claudel
2017-03-16 15:27                                                                                               ` Eli Zaretskii
2017-03-16 21:23                                                                                                 ` Clément Pit--Claudel
2017-03-17  8:15                                                                                                   ` Eli Zaretskii
2017-04-16  7:48                                                                                                 ` Eli Zaretskii
2017-04-16 15:28                                                                                                   ` Clément Pit--Claudel
2016-12-19 17:00                                                     ` Clément Pit--Claudel
2015-07-10 15:42 ` Glenn Morris
2016-03-03  6:37   ` Clément Pit--Claudel
2016-10-04 18:56 ` Jason Gross
2017-03-13 15:54 ` bug#21028: Slow font rendering in emacs Ralf Jung
2017-03-13 17:05   ` Eli Zaretskii
2017-03-13 18:12     ` Ralf Jung
2017-03-13 20:39       ` Eli Zaretskii
2017-03-14 15:57         ` Ralf Jung
2017-03-14 17:11           ` Eli Zaretskii
2017-03-14 18:50             ` Ralf Jung
2017-03-14 19:16               ` Eli Zaretskii
2017-03-14 19:17             ` Ralf Jung
2017-03-14 20:49             ` John Mastro
2017-03-15 15:40               ` Eli Zaretskii
2017-03-14 15:47   ` Eli Zaretskii
2017-03-14 18:41     ` Ralf Jung
2017-03-14 19:16       ` Eli Zaretskii
2017-03-14 19:39         ` Ralf Jung
2017-03-14 19:45           ` Ralf Jung
2017-03-15 15:36           ` Eli Zaretskii
2017-04-22  8:54             ` Ralf Jung
2017-04-22 13:40               ` 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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83k27rc15x.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=21028@debbugs.gnu.org \
    --cc=clement.pitclaudel@live.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 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.