From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?UTF-8?Q?Cl=C3=A9ment?= Pit-Claudel Newsgroups: gmane.emacs.bugs Subject: bug#41200: Displaying a tooltip with x-show-tip gets very slow as more faces are defined Date: Fri, 15 May 2020 15:10:46 -0400 Message-ID: <9c487146-1fad-0301-fe1a-8d98d560c6ea@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="54842"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 Cc: 41200@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 15 21:11:12 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jZfjk-000E9W-Ne for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 15 May 2020 21:11:12 +0200 Original-Received: from localhost ([::1]:60474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZfjj-00075w-Oc for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 15 May 2020 15:11:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZfja-00074T-6d for bug-gnu-emacs@gnu.org; Fri, 15 May 2020 15:11:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55449) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jZfjZ-0003XY-Tn for bug-gnu-emacs@gnu.org; Fri, 15 May 2020 15:11:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jZfjZ-0006lo-Px for bug-gnu-emacs@gnu.org; Fri, 15 May 2020 15:11:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Cl=C3=A9ment?= Pit-Claudel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 May 2020 19:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41200 X-GNU-PR-Package: emacs Original-Received: via spool by 41200-submit@debbugs.gnu.org id=B41200.158956985526011 (code B ref 41200); Fri, 15 May 2020 19:11:01 +0000 Original-Received: (at 41200) by debbugs.gnu.org; 15 May 2020 19:10:55 +0000 Original-Received: from localhost ([127.0.0.1]:38762 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZfjS-0006lT-Sa for submit@debbugs.gnu.org; Fri, 15 May 2020 15:10:55 -0400 Original-Received: from mail-qt1-f176.google.com ([209.85.160.176]:37277) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZfjR-0006lE-EC for 41200@debbugs.gnu.org; Fri, 15 May 2020 15:10:53 -0400 Original-Received: by mail-qt1-f176.google.com with SMTP id 4so2929123qtb.4 for <41200@debbugs.gnu.org>; Fri, 15 May 2020 12:10:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=tTb7Py8eeG3LXI4jHQF7dCD6b+Up2Nv9u+5sc/08wDQ=; b=Y9548F4uV6mAXVtteG8QTQsS5v6P5JCRcXK68zgWnlxKjaOGEK+zCR8GvQdEe5Pgq1 yidaMvMCpI8Mm0khyOpSfdOkEz8hk5Y3Lap0LFIYVhenwtS7nKq0q0EbleNzfxlvMeBQ 5W9TrJzJI1w1JKMcgHDrt47NDvXkkEYoMQeNAjz3aVZ7TMxWypREx7y5ankeWb01EXOy YH+5pVJoap0Jco3mkih+bX8om6bErR07vj1KqiVa/2FcnnGv6qFmGhM5aMQtCTCu2/r5 CvLq6eIl26ZnolRVe+9d8+CzFjmE7m2iFCvqyFCRGD0RsVDvzjRNm+Kz2VQN8CsCQc8E Iqvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=tTb7Py8eeG3LXI4jHQF7dCD6b+Up2Nv9u+5sc/08wDQ=; b=p9RQWpt+PbBkyC9y/JIttAG16dylXwvxddY8EkTwVgSZf958wUxUOrvf+e/m71Vbi0 nQM2I6r8DAQjODfO5JtSJCzeJr1onxchRDi7ynQ3SEbE2MBeFpazMC5f2xXoduIw7CRl Tz1dSF0XjuA5FHtdKpJB5LbMMOuH9YyRCKTDa91R/5HVPVTmyca0+QOj54b69Q1KPXSy 7IjH3sPyFMtrgxedCcksWS1KXeGuOpg0RGMwmHhTcHusuS9wSS5NtszRcU/LT78y2snE AgnbygmMTNpIdcp9mxuglEgAe1XtbgkdgPjQMQ5GsRDBBzVjPfrNUCLknnRDp5j1NszP fmAQ== X-Gm-Message-State: AOAM532gfaZp+p4t+bNvKHJyBrJl4hxMHZwvNjlzuslhmMJZ5quIxgQv 8IuMp54dB9aeKXxFWM63AjtWtVfy X-Google-Smtp-Source: ABdhPJwVsKdYjdUyQClv3rqPOIKAP37uPD/NoY+ah05yBN12KMIhOjkh+JRFRr6frJl3qZ3Htthq4A== X-Received: by 2002:aed:3bda:: with SMTP id s26mr5209337qte.261.1589569847676; Fri, 15 May 2020 12:10:47 -0700 (PDT) Original-Received: from ?IPv6:2601:184:4180:66e7:4d17:b25e:8d9:2188? ([2601:184:4180:66e7:4d17:b25e:8d9:2188]) by smtp.googlemail.com with ESMTPSA id 17sm2211057qkn.44.2020.05.15.12.10.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 May 2020 12:10:47 -0700 (PDT) In-Reply-To: Content-Language: en-GB X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:180355 Archived-At: On 15/05/2020 10.03, Stefan Monnier wrote: >> Indeed, you're completely right; thanks! Replacing face_alist and >> Vface_new_frame_defaults with hash tables makes the worst example >> about 10 times faster, and with that change tooltips now take 30 to >> 50ms to display instead of 500-600ms in my real-life use case (my >> usual config). I have attached a patch. > > Oh, this is great, makes a very noticeable difference. Thanks for testing! > The variable's name did not say "alist", so I don't see a need to change > it from that point of view. But I think it deserves a "--" since it's > supposed to be internal. Ah, that's a good point. At least, renaming it will make it clear that something changed and make it easy to support older and newer emacsen. > A quick grep revealed: > > elpa/packages/context-coloring/fixtures/benchmark/faces.el: (mapcar #'car face-new-frame-defaults)) AFAICT, this is just a copy of faces.el, used to benchmark syntax highlighting (that is, this code is not run). >> - command-execute 454 47% > [...] >> - face-set-after-frame-default 387 40% >> - face-spec-recalc 374 39% >> - make-face-x-resource-internal 296 30% >> - set-face-attributes-from-resources 273 28% >> - set-face-attribute-from-resource 219 22% > > [...] > >> - command-execute 768 80% > [...] >> - face-set-after-frame-default 674 70% >> - face-spec-recalc 660 69% >> - face-spec-set-2 350 36% >> - apply 348 36% >> - set-face-attribute 342 35% >> - internal-set-lisp-face-attribute 342 35% >> - frame-set-background-mode 331 34% >> - face-spec-recalc 284 29% >> - make-face-x-resource-internal 235 24% > > Both of those profiles suggest that most of the time is still spent in > `face-spec-recalc`, so it would be worth trying harder to avoid calling > it or to speed it up somehow (presumably with some better memozing/caching). Interesting. I also wonder whether we could fast-track the case where the face spec is a vector full of 'undefined, since that seems to be the common case.