From: "Clément Pit--Claudel" <clement.pitclaudel@live.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 21028@debbugs.gnu.org
Subject: bug#21028: Performance regression in revision af1a69f4d17a482c359d98c00ef86fac835b5fac (Apr 2014).
Date: Tue, 14 Mar 2017 15:35:01 -0400 [thread overview]
Message-ID: <79f4e3ce-6284-8fc5-fd8f-9f0c9cebe873@live.com> (raw)
In-Reply-To: <83k27rc15x.fsf@gnu.org>
[-- Attachment #1.1: Type: text/plain, Size: 10345 bytes --]
On 2017-03-14 11:45, Eli Zaretskii wrote:
> 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.
Is there a way to tell Emacs to use them for everything they support? For example, Ubuntu Mono supports box-drawing characters (so I could add that range), but it also supports U+2202 "partial diff", U+2206 "Delta", U+2211 "summation", and U+222B "integral", and a few other symbols (≠, ≤, …).
> 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:
I do :) See timings below:
# With your patch
$ time master/src/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))"
real 0m0.532s
user 0m0.404s
sys 0m0.024s
# Without your patch
$ time 25.1/src/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))"
real 0m0.577s
user 0m0.392s
sys 0m0.020s
And more experiments:
# With just 'latin (no registry) on stock 25.1:
$ time 25.1/src/emacs -Q --eval "(progn (set-fontset-font \"fontset-default\" 'latin \"Noto Sans\" nil) (set-fontset-font \"fontset-default\" '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 0m0.587s
user 0m0.416s
sys 0m0.012s
# With just the registries (and 'unicode instead of 'latin) on stock 25.1
$ time 25.1/src/emacs -Q --eval "(progn (set-fontset-font \"fontset-default\" 'unicode '(\"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))"
real 0m42.250s
user 0m22.148s
sys 0m6.220s
# With 'unicode and inhibit-compacting-font-caches on stock 25.1:
$ time 25.1/src/emacs -Q --eval "(progn (setq inhibit-compacting-font-caches t) (set-fontset-font \"fontset-default\" 'unicode '(\"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))"
real 0m42.105s
user 0m22.340s
sys 0m6.124s
> 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.
>
For me specifying the registry doesn't seem to do anything, but restricting the font to 'latin does. Is that example right though? On my machine, running the code above gives me an Emacs that uses Ubuntu Mono and Symbola, not Noto Sans. I need to use "fontset-startup" for the font to be taken into account.
To clarify, the following uses Noto Sans and XITS Math, and is very slow:
$ time 25.1/src/emacs -Q --eval "(progn (set-fontset-font \"fontset-startup\" 'unicode \"Noto Sans\" nil) (set-fontset-font \"fontset-startup\" 'unicode \"XITS Math\" 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))"
The following uses *Ubuntu Mono* (?!) and XITS Math, and is very slow
$ time 25.1/src/emacs -Q --eval "(progn (set-fontset-font \"fontset-default\" 'unicode \"Noto Sans\" nil) (set-fontset-font \"fontset-default\" 'unicode \"XITS Math\" 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))"
The following uses Noto Sans and XITS Math, and is very fast:
$ time 25.1/src/emacs -Q --eval "(progn (set-fontset-font \"fontset-startup\" 'latin \"Noto Sans\" nil) (set-fontset-font \"fontset-startup\" 'unicode \"XITS Math\" 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'm a bit confused, though: the restriction to latin still allows Emacs to use Noto Sans for characters like "⅔", "≠", and "√"?
> 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 874.
> 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:
>
> All of the above specs lack a proper :registry value, which should
> be 'iso10646-1.
Thanks.
> (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.
But I want more tha 'latin, 'greek, and 'cyrillic: I want "any character that this font supports".
> (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.
Possibly — but this will break next time the font is updated with more Emoji, right?
> (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.
I used a variant of Symbola, not Symbola itself.
> (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.
Thanks, good point!
> 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 sure I understand. Are you saying that e.g. running the following should show display a *scratch* buffer in Noto Sans?
$ 25.1/src/emacs -Q --eval "(set-fontset-font \"fontset-default\" 'latin \"Noto Sans\" nil)"
It doesn't for me. I need to set fontset-startup instead.
$ 25.1/src/emacs -Q --eval "(set-fontset-font \"fontset-startup\" 'latin \"Noto Sans\" nil)"
But then I run into trouble when I change the font size (with set-face-attribute), because that creates new fontsets.
>> 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).
For me that example is fast in all configurations: the problem I ran into with CJK scripts was 2 years ago, and I haven't managed to reproduce it.
> Can you ask some of those people to show their fontset setup? I'd
> like to know how different they are from your setup.
They essentially use this:
(dolist (ft (fontset-list))
(set-fontset-font ft 'unicode (font-spec :name "YOUR-USUAL-FONT"))
(set-fontset-font ft 'unicode (font-spec :name "Symbola") nil 'append))
because that's what I recommend (that's the only one that I've found to work reliably: not specifying 'unicode uses Symbola too often, not looping on the fontsets causes issues when changing font sizes, and not specifying Symbola sometimes falls back to other fonts). It used to work great in Emacs 24.3, which was the default on Ubuntu for a while (and still is for the long-term support release)
> Btw, I'm still trying to understand the significance of the proposed
> patch, although it's hard without a clear-cut test case.
Thanks for your help!
Clément.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2017-03-14 19:35 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
2017-03-14 19:35 ` Clément Pit--Claudel [this message]
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
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=79f4e3ce-6284-8fc5-fd8f-9f0c9cebe873@live.com \
--to=clement.pitclaudel@live.com \
--cc=21028@debbugs.gnu.org \
--cc=eliz@gnu.org \
/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).