[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [External] : Passing buffers to function in elisp
From: |
Petteri Hintsanen |
Subject: |
Re: [External] : Passing buffers to function in elisp |
Date: |
Mon, 27 Feb 2023 22:44:43 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
Stefan Monnier via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
>> If `emms-info-native--read-and-decode-ogg-page' is called very often
>> (hundreds of times or more), it's probably better to use one single
>> buffer instead of a fresh temp buffer every single time.
I tried this and, for a moment, I _think_ it shaved off something like
20-25% of the memory usage (according to the memory profiler). That
would be a big win.
Sadly enough, it was just for a moment, because I cannot replicate it
anymore. It wasn't a particularly controlled setup, so probably I just
messed up something at some point. Nonetheless, using a persistent
buffer seems to be the right thing to do, and seeing how many
" *foo-bar-baz*" buffers there are, it even looks like a pattern.
Also, if I interpreted profiler's hieroglyphs correctly, it told me that
this setq
(setq stream (vconcat stream (plist-get page :stream)))
is a pig -- well, of course it is. I'm accumulating byte vector by
copying its parts. Similarly bindat consumes a lot of memory.
I think I can replace vectors with strings, which should, according to
the elisp manual, "occupy one-fourth the space of a vector of the same
elements." And I guess that accumulation would be best done with a
buffer, not with strings or vectors.
But bindat internals are beyond me.
> That's definitely something to consider. Another is whether the ELisp
> code was byte-compiled (if not, then all bets are off, the interpreter
> itself generates a fair bit of garbage, especially if you use a lot of
> macros).
No, it was not byte-compiled. I don't know how many macros there are.
Just by hand-waving I'd say "not that many". But again what bindat does
is beyond me.
I'll try byte-compiling after the code is in good enough shape to do
controlled experiments.
> Are you using `bindat-type`?
No, not yet. I have been thinking about it, not only because the
current implementation is riddled with ugly evals and kludges, but I
want to save the kittens ;-D
I also need to discuss with EMMS maintainer whether using Emacs 28+
feature is okay.
Thanks to all for insights, I learned a lot.
Petteri
- Passing buffers to function in elisp, Petteri Hintsanen, 2023/02/21
- RE: [External] : Passing buffers to function in elisp, Drew Adams, 2023/02/21
- Re: [External] : Passing buffers to function in elisp, tomas, 2023/02/22
- Re: [External] : Passing buffers to function in elisp, Petteri Hintsanen, 2023/02/24
- Re: [External] : Passing buffers to function in elisp, tomas, 2023/02/25
- Re: [External] : Passing buffers to function in elisp, Michael Heerdegen, 2023/02/25
- Re: [External] : Passing buffers to function in elisp, tomas, 2023/02/25
- Re: [External] : Passing buffers to function in elisp, Michael Heerdegen, 2023/02/25
- Re: [External] : Passing buffers to function in elisp, tomas, 2023/02/25
- Re: [External] : Passing buffers to function in elisp, Stefan Monnier, 2023/02/25
- Re: [External] : Passing buffers to function in elisp,
Petteri Hintsanen <=
- Re: [External] : Passing buffers to function in elisp, tomas, 2023/02/28
Re: Passing buffers to function in elisp, tomas, 2023/02/22