From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#21028: Performance regression in revision af1a69f4d17a482c359d98c00ef86fac835b5fac (Apr 2014). Date: Tue, 14 Mar 2017 17:45:30 +0200 Message-ID: <83k27rc15x.fsf@gnu.org> References: <559F9FAF.8090708@live.com> <831sz0sfug.fsf@gnu.org> <83oa095eaw.fsf@gnu.org> <83lgvd581m.fsf@gnu.org> <83a8br6hq0.fsf@gnu.org> <672a0c69-4352-735f-cba4-025e642626ea@gmail.com> <83vauf50wb.fsf@gnu.org> <7408d59c-92ba-b879-5ac1-3cd5eee9b4db@gmail.com> <83tw9z4zzp.fsf@gnu.org> <2cad0da9-c931-b547-07bb-efec2f2bcf1f@gmail.com> <83h95w0w3p.fsf@gnu.org> <27853273-e6d8-077e-b9e0-b2bec2fe1fae@gmail.com> <834m1v2630.fsf@gnu.org> <1c224dc1-bd71-a910-b7cf-00313e4aec40@live.com> <83efy2cx5n.fsf@gnu.org> <3c3e8384-3412-f5a5-3ab2-a7eb4e699f1c@live.com> <83d1dmcrnl.fsf@gnu.org> <39fe847e-ef8a-149f-4478-d02e7c794c9a@live.com> <837f3tch7y.fsf@gnu.org> <1e7bc066-3f29-3897-5039-de7233efc58a@live.com> <83y3w9ay6y.fsf@gnu.org> <16f9db27-dd0f-ddaf-2f34-45b9fd4e69c6@live.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1489506457 12120 195.159.176.226 (14 Mar 2017 15:47:37 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 14 Mar 2017 15:47:37 +0000 (UTC) Cc: 21028@debbugs.gnu.org To: =?UTF-8?Q?Cl=C3=A9ment?= Pit--Claudel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Mar 14 16:47:31 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnofX-0002EZ-Hx for geb-bug-gnu-emacs@m.gmane.org; Tue, 14 Mar 2017 16:47:27 +0100 Original-Received: from localhost ([::1]:60234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnofd-00009Y-NT for geb-bug-gnu-emacs@m.gmane.org; Tue, 14 Mar 2017 11:47:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnofB-0008MT-QB for bug-gnu-emacs@gnu.org; Tue, 14 Mar 2017 11:47:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnof7-0006uY-Us for bug-gnu-emacs@gnu.org; Tue, 14 Mar 2017 11:47:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57639) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cnof7-0006uS-Qt for bug-gnu-emacs@gnu.org; Tue, 14 Mar 2017 11:47:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cnof7-0005Nq-KX for bug-gnu-emacs@gnu.org; Tue, 14 Mar 2017 11:47:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 Mar 2017 15:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21028 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21028-submit@debbugs.gnu.org id=B21028.148950637718427 (code B ref 21028); Tue, 14 Mar 2017 15:47:01 +0000 Original-Received: (at 21028) by debbugs.gnu.org; 14 Mar 2017 15:46:17 +0000 Original-Received: from localhost ([127.0.0.1]:55838 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnoeL-0004jy-8K for submit@debbugs.gnu.org; Tue, 14 Mar 2017 11:46:16 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:60671) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnoeJ-0004e0-Kd for 21028@debbugs.gnu.org; Tue, 14 Mar 2017 11:46:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnoeA-0006Sb-EL for 21028@debbugs.gnu.org; Tue, 14 Mar 2017 11:46:06 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:39663) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnoeA-0006SP-54; Tue, 14 Mar 2017 11:46:02 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4361 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cnoe9-00038f-GW; Tue, 14 Mar 2017 11:46:01 -0400 In-reply-to: <16f9db27-dd0f-ddaf-2f34-45b9fd4e69c6@live.com> (message from =?UTF-8?Q?Cl=C3=A9ment?= Pit--Claudel on Mon, 13 Mar 2017 15:04:24 -0400) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:130574 Archived-At: > Cc: 21028@debbugs.gnu.org > From: Clément Pit--Claudel > 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.