unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Clément Pit-Claudel" <cpitclaudel@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 41200@debbugs.gnu.org, Anders Lindgren <andlind@gmail.com>
Subject: bug#41200: Displaying a tooltip with x-show-tip gets very slow as more faces are defined
Date: Fri, 15 May 2020 12:22:53 -0400	[thread overview]
Message-ID: <e47117f7-6f19-9ef5-39ba-8220dfd0980f@gmail.com> (raw)
In-Reply-To: <835zcxgrby.fsf@gnu.org>

On 15/05/2020 11.17, Eli Zaretskii wrote:
>>>> * The name face_hash isn't ideal, since there's already a distinct notion of face hashes (hash codes).  Can you think of a better name? 
>>>
>>> face_hash_table?
>>
>> Thanks, good idea.  I also liked Stefan's frame_face_map.
> 
> "Map" is too general, IMO, it doesn't tell enough about the kind of
> object it is.

Got it.  Is face_table better? (that was Stefan's other suggestion)
 
>>> And I'm not sure we should have it only in Lisp: perhaps we should
>>> maintain the alist as well, and add/remove to/from it when a face is
>>> added or removed in the hash table.  Otherwise this change of
>>> internals will have painful effect on packages that use the current
>>> APIs.
>>
>> frame-face-alist is likely less crucial than face-new-frame-defaults, because it was already a function, so the return value has to be mutated in place to modify it (it couldn't be directly assigned).  For both of these, however, how would we ensure that the alist remains in sync with the hashmap (that is, how do we catch modifications?)
> 
> I thought about updating the alist when the hash-table is modified.
> Since you always know whether the face is already in the hash-table,
> you don't need to scan the alist looking for it.

Would that be done in C, or in any place where frame-new-face-defaults is modified?  (for example, edebug changes face-new-frame-defaults in one place; if we keep the alist in addition to the hash table, would it modify both or would there be a C mechanism that mirrors hash-table modifications to the alist?)

> I'd really like to know that no one is using these before we make the
> final decision about this.

That's a fair point.  While I couldn't find uses of frame-face-alist, there are a few uses of face-new-frame-defaults-alist: https://github.com/pestctrl/emacs-config/commit/31d6bff97dacf60f71066902a23d37e59b4c1288 is from someone who uses that to speed up temporary frame creation(!), https://github.com/Lindydancer/face-explorer/blob/13bd4553bc4b09215a04d0267be1cb4ed834775c/test/face-explorer-test-faces.el is from Anders Lindgren (in CC; hi Andres! We're considering replacing face-new-frame-defaults-alist with a hash table, would that be an issue?), who uses it to remove a face, and https://github.com/Wilfred/elisp-fu/blob/92c491584f466ee729ea1b328234636e65e2c665/elisp-fu.el includes code that's the same as in eval-defun.

I have a variant of the patch that keeps the alist variable, but I fear that it's worse than removing it: since changes to the alist won't be propagated to the hash table, it might be better to error out with a compilation error?

Btw, I have one more question: some callers of face-list seems to rely on the order of faces added to it, so it would be better to preserve that order.  Since hash-tables are not necessarily ordered, should I sort faces by face-id before returning them? 

>> If so, where from?
> 
> I think the problem is that tab-line is declared a basic face, but its
> defface form is not in faces.el.

Ah, good catch.  Current there's a defface for tab-bar in lisp/tab-bar, and since that's preloaded it works, but the defface for tab-line is in lisp/tab-line.el and so isn't preloaded.
Should I move both to faces.el?
 
>>>> +          if (!FIXNATP (face_id))
>>>> +            // FIXME: I'm not sure what to do in this case
>>>
>>> I'm not sure I understand why do you need to look at the existing
>>> face's 'face' property?  The original code didn't.
>>
>> The original code iterated over face-frame-alist in the order in which entries were added to it.  If I understand correctly, iteration order isn't guaranteed on hash tables (is it?), so I had to find a different source of truth for these.
> 
> Maybe we should store the ID with the face?  I think we wanted to get
> rid of the 'face' property of the faces at some point.

Sounds reasonable; but where would we store it?  Right now faces are just symbols, right?

> No, I was asking why not start with it as nil and actually make a
> hash-table when we first need it.

Oh, I thought it would be simpler to always have a hash table instead of having to sanity check every time.

Thanks a lot,
Clément.





  parent reply	other threads:[~2020-05-15 16:22 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-12  4:30 bug#41200: Displaying a tooltip with x-show-tip gets very slow as more faces are defined Clément Pit-Claudel
2020-05-12  6:42 ` martin rudalics
2020-05-12 11:30   ` Clément Pit-Claudel
2020-05-12 15:12     ` martin rudalics
2020-05-12 17:19       ` Clément Pit-Claudel
2020-05-12 17:42         ` martin rudalics
2020-05-12 17:58           ` Eli Zaretskii
2020-05-13 14:58             ` martin rudalics
2020-05-12 15:27 ` Eli Zaretskii
2020-05-13  2:41   ` Clément Pit-Claudel
2020-05-13 14:58     ` martin rudalics
2020-05-13 15:13       ` Clément Pit-Claudel
2020-05-13 17:42         ` martin rudalics
2020-05-15 11:05     ` Eli Zaretskii
2020-05-15 14:59       ` Clément Pit-Claudel
2020-05-15 15:17         ` Eli Zaretskii
2020-05-15 15:33           ` Noam Postavsky
2020-05-15 16:22           ` Clément Pit-Claudel [this message]
2020-05-15 17:28             ` Eli Zaretskii
2020-05-15 18:50               ` Clément Pit-Claudel
2020-05-15 19:05                 ` Eli Zaretskii
2020-05-15 19:23                   ` Clément Pit-Claudel
2020-05-15 19:38                     ` Eli Zaretskii
2020-05-15 19:52                       ` Clément Pit-Claudel
2020-05-16 23:03                 ` Juri Linkov
2020-05-16 23:43                   ` Clément Pit-Claudel
2020-05-17 21:59                     ` Juri Linkov
2020-05-18  1:19                       ` Clément Pit-Claudel
2020-05-19 21:48                         ` Juri Linkov
     [not found]                           ` <83a71z135p.fsf@gnu.org>
2020-05-23 22:47                             ` Juri Linkov
2020-05-24  2:33                               ` Eli Zaretskii
2020-05-24 21:50                                 ` Juri Linkov
2020-06-08  0:21                             ` Juri Linkov
2020-06-20  7:47                               ` Eli Zaretskii
2020-06-20 16:55                                 ` Clément Pit-Claudel
2020-07-04  7:58                                   ` Eli Zaretskii
2020-09-13  2:53                                     ` Benson Chu
2020-05-15 14:03 ` Stefan Monnier
2020-05-15 14:34   ` Eli Zaretskii
2020-05-15 19:10   ` Clément Pit-Claudel
2020-05-15 21:23     ` Stefan Monnier
2020-05-16  8:45       ` martin rudalics
2021-04-06  6:35 ` Jashank Jeremy
2021-04-06 12:30   ` Eli Zaretskii
2021-04-06 15:07     ` Clément Pit-Claudel
2021-04-06 15:50       ` Eli Zaretskii
2021-04-23  3:56   ` Stefan Monnier
2021-05-12 20:29     ` Lars Ingebrigtsen
2021-05-13  3:56       ` Jashank Jeremy
2021-05-13  9:15         ` Lars Ingebrigtsen
2021-05-13 23:26           ` Jashank Jeremy
2021-06-12 12:15             ` Lars Ingebrigtsen
2021-06-13  3:19               ` Richard Stallman
2021-07-06 12:41               ` Aaron Jensen
2021-07-21 14:02         ` Lars Ingebrigtsen
2021-07-21 14:28           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-07-21 14:32             ` Clément Pit-Claudel

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=e47117f7-6f19-9ef5-39ba-8220dfd0980f@gmail.com \
    --to=cpitclaudel@gmail.com \
    --cc=41200@debbugs.gnu.org \
    --cc=andlind@gmail.com \
    --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).