[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Caching where-is-internal
From: |
Stefan Monnier |
Subject: |
Re: Caching where-is-internal |
Date: |
Mon, 24 May 2021 15:53:27 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> I think the problem was that `where-is-internal` can generate a lot of
> garbage memory. In Marginalia we have this code:
It would be great if you could track it down further.
Maybe it's simply that the cache ends up flushed between invocations
(in your use case), defeating its purpose.
> (mapatoms
> (lambda (sym)
> (when-let (key (and (commandp sym)
> (where-is-internal sym nil t)))
> (puthash sym key marginalia--annotate-binding-hash)))))
`where-is-internal` has almost exactly this same hash-table internally, so
this basically copies the hash-table (in a somewhat inefficient way).
:-(
> But I cannot tell you much about the exact reasons. It just turned out
> that calling `where-is-internal` once on all symbols was faster than
> calling it occasionally.
I suspect a "spurious cache flush". Maybe we should export the code
that turns a set of keymaps into a (reversed) hash-table.
> The funny thing here is that the initial (costly?) computation of the
> `marginalia--annotate-binding-hash` does not lead to a noticeable slowdown.
The first call to `where-is-internal` will traverse all the keymaps and
build the hash-table (which doesn't cost much more than just a plain
uncached `where-is-internal`), and the subsequent ones will hit the
hash-table instead.
Stefan
- Re: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations, (continued)
- Re: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations, Daniel Mendler, 2021/05/23
- Re: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations, Dmitry Gutov, 2021/05/23
- Re: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations, Stefan Monnier, 2021/05/23
- Re: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations, Juri Linkov, 2021/05/23
- Re: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations, Dmitry Gutov, 2021/05/24
- Re: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations, Juri Linkov, 2021/05/23
- Re: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations, Stefan Monnier, 2021/05/23
- Re: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations, Daniel Mendler, 2021/05/24
- Caching where-is-internal (was: (icomplete-vertical-mode): Add support for affixations and, annotations), Stefan Monnier, 2021/05/24
- Re: Caching where-is-internal (was: (icomplete-vertical-mode): Add support for affixations and, annotations), Daniel Mendler, 2021/05/24
- Re: Caching where-is-internal,
Stefan Monnier <=
- Re: Caching where-is-internal, Daniel Mendler, 2021/05/24
- Re: Caching where-is-internal, Stefan Monnier, 2021/05/24
- Re: Caching where-is-internal, Daniel Mendler, 2021/05/24
- Re: Caching where-is-internal, Stefan Monnier, 2021/05/24
- Re: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations, Juri Linkov, 2021/05/24
- Re: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations, João Távora, 2021/05/24
- Re: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations, Stefan Monnier, 2021/05/24
- Re: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations, João Távora, 2021/05/24
- Re: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations, Juri Linkov, 2021/05/25
- Re: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations, Stefan Monnier, 2021/05/25