~protesilaos/tmr

4 2

Document minibuffer histories; add savehist sample

Daniel Mendler <mail@daniel-mendler.de>
Details
Message ID
<f27ecd11-a685-f3ff-c4fa-084149b35969@daniel-mendler.de>
DKIM signature
missing
Download raw message
Hello Prot,

I saw that you documented a savehist sample. I want to warn about too
large values for history-length since this leads to a high memory cost
(M-x memory-report), which potentially slows down Emacs and garbage
collection as a whole. I used to use such large values myself but
settled on 500 for now. Vertico uses sorting by history and this becomes
also slightly more expensive or large histories. It is O(n) so it scales
well for large histories.

Daniel
Details
Message ID
<87k08o6cei.fsf@protesilaos.com>
In-Reply-To
<f27ecd11-a685-f3ff-c4fa-084149b35969@daniel-mendler.de> (view parent)
DKIM signature
missing
Download raw message
> From: Daniel Mendler <mail@daniel-mendler.de>
> Date: Thu, 07 Jul 2022 19:43:01 +0200
>
> Hello Prot,

Hello Daniel,

> I saw that you documented a savehist sample. I want to warn about too
> large values for history-length since this leads to a high memory cost
> (M-x memory-report), which potentially slows down Emacs and garbage
> collection as a whole. I used to use such large values myself but
> settled on 500 for now. Vertico uses sorting by history and this becomes
> also slightly more expensive or large histories. It is O(n) so it scales
> well for large histories.

Oh, I have been running this setting probably for more than a year
without ever realising!  I will update the manual right away, though I
already cut a release.  Do you think this merits a version change to
0.4.1?

All the best,
Prot

-- 
Protesilaos Stavrou
https://protesilaos.com
Daniel Mendler <mail@daniel-mendler.de>
Details
Message ID
<97a660b7-d218-fff5-d935-9d9e1fdc6b68@daniel-mendler.de>
In-Reply-To
<87k08o6cei.fsf@protesilaos.com> (view parent)
DKIM signature
missing
Download raw message
> Oh, I have been running this setting probably for more than a year
> without ever realising!  I will update the manual right away, though I
> already cut a release.  Do you think this merits a version change to
> 0.4.1?

Maybe it works all well for you. I just recommend to keep an eye on
this. There is no need for a new release, but you could add a note to
the manual. People should experiment with various values and in case of
doubt rely on the default values. Usually such tuning parameters are set
conservatively in Emacs which is good for most environments.

I do disagree with the default GC settings though. These have been stuck
too far in the past, while most users use newer machines these days (by
new I mean 5 or 10 years old). I assume you also use increased GC values
in your configuration?

Daniel
Details
Message ID
<87h73s6b8p.fsf@protesilaos.com>
In-Reply-To
<97a660b7-d218-fff5-d935-9d9e1fdc6b68@daniel-mendler.de> (view parent)
DKIM signature
missing
Download raw message
> From: Daniel Mendler <mail@daniel-mendler.de>
> Date: Thu, 07 Jul 2022 20:05:46 +0200
>
>> Oh, I have been running this setting probably for more than a year
>> without ever realising!  I will update the manual right away, though I
>> already cut a release.  Do you think this merits a version change to
>> 0.4.1?
>
> Maybe it works all well for you. I just recommend to keep an eye on
> this. There is no need for a new release, but you could add a note to
> the manual. People should experiment with various values and in case of
> doubt rely on the default values. Usually such tuning parameters are set
> conservatively in Emacs which is good for most environments.

Okay, I will now update the manual to 500.

> I do disagree with the default GC settings though. These have been stuck
> too far in the past, while most users use newer machines these days (by
> new I mean 5 or 10 years old). I assume you also use increased GC values
> in your configuration?

I have not touched GC because I do not know enough about the potential
downsides.  I see people tweak it to get better startup times.  I do not
worry about those, as I only launch Emacs once per session, go fetch
some water, and by the time I am back everything is running as expected.

-- 
Protesilaos Stavrou
https://protesilaos.com
Daniel Mendler <mail@daniel-mendler.de>
Details
Message ID
<344ffa32-86a6-82df-829a-ad03db560d7c@daniel-mendler.de>
In-Reply-To
<87h73s6b8p.fsf@protesilaos.com> (view parent)
DKIM signature
missing
Download raw message
On 7/7/22 20:14, Protesilaos Stavrou wrote:
>> From: Daniel Mendler <mail@daniel-mendler.de>
>> Date: Thu, 07 Jul 2022 20:05:46 +0200
>>
>>> Oh, I have been running this setting probably for more than a year
>>> without ever realising!  I will update the manual right away, though I
>>> already cut a release.  Do you think this merits a version change to
>>> 0.4.1?
>>
>> Maybe it works all well for you. I just recommend to keep an eye on
>> this. There is no need for a new release, but you could add a note to
>> the manual. People should experiment with various values and in case of
>> doubt rely on the default values. Usually such tuning parameters are set
>> conservatively in Emacs which is good for most environments.
> 
> Okay, I will now update the manual to 500.

My suggestion would be to recommend that users should try out different
values, but should be aware of the potential up- and downsides.

>> I do disagree with the default GC settings though. These have been stuck
>> too far in the past, while most users use newer machines these days (by
>> new I mean 5 or 10 years old). I assume you also use increased GC values
>> in your configuration?
> 
> I have not touched GC because I do not know enough about the potential
> downsides.  I see people tweak it to get better startup times.  I do not
> worry about those, as I only launch Emacs once per session, go fetch
> some water, and by the time I am back everything is running as expected.

I also disable the GC during startup which leads to a significant
speedup. My Emacs setup starts quickly in 0.4s, which is not enough time
to drink some water. ;)

Still, I don't restart Emacs often, since Emacs should better be used
continuously. Even then, optimizing startup speed has the positive side
effect of setting up packages properly for lazy loading. Many user
configurations just require a bunch of packages one by one. I prefer the
use-package approach where things are delayed as much as possible. This
is also helpful as a package developer since I have to take a lot of
care about the various interdependencies of packages and the proper
definition of autoloads.

Also if you develop your packages for lazy loading in mind, you
necessarily have to follow certain patterns. If we take TMR as an
example, we could define a tmr-prefix-map which could be bound to C-c t
in the user configuration. This would help the user since they wouldn't
have to bind all the commands one by one. On the other hand, lazily
loading keymaps is not something easily supported by Emacs, so we would
have to load the package right away before binding the keymap. For this
reason it is better to avoid this keymap definition style. Use-package
has a hack to support lazily loaded keymaps, but I've stopped relying on
use-package since then, relying on bare essentials instead.

Another example are global minor modes or setup functions like
`ffap-bindings` or `windmove-default-bindings`, which I consider bad
practice. If you use global minor modes and turn them on immediately,
this will force loading the package. I use global modes for Vertico and
Corfu. For Vertico that's justified since you probably use that anyway
immediately (deferring until first keypress would be possible), but for
Corfu one could enable the local corfu-mode only per major mode, such
that loading would be deferred. My org-modern package also comes with a
global-org-modern-mode. In this case I recommend to not enable this mode
right away, but to defer it until Org is loaded, `(with-eval-after-load
'org (global-org-modern-mode))`.

Daniel
Reply to thread Export thread (mbox)