Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: SSD-friendly history



On Wed, Oct 5, 2022 at 4:19 PM Dominik Vogt <dominik.vogt@xxxxxx> wrote:
>
> Disk space is not an issue.  So, if I set
>
>   SAVEHIST=120000
>   HISTSIZE=100000
>
> Then only 100.000 lines are loaded when the shell starts?

The shell will read all 120000 lines and keep the last (most recent)
100000 of them.  So there's a slight startup speed penalty.

> But how does this interact with duplicate handling, especially
> with HIST_EXPIRE_DUPS_FIRST?

Duplicate handling all happens on the in-memory history.   This means
anything that suppresses duplicates from the HISTFILE (such as
HIST_SAVE_NO_DUPS) will end up reducing it to HISTSIZE lines even if
SAVEHIST is larger.  The doc thus recommends setting HISTSIZE larger
than SAVEHIST in the case of HIST_EXPIRE_DUPS_FIRST so that you don't
immediately begin discarding your saved history as commands are
entered (which might be important if e.g. you use
accept-and-infer-next-history a lot).  However, if you use
INC_APPEND_HISTORY, duplicates are removed from HISTFILE only when
that file is rewritten (at SAVEHIST + 20% while the shell is
incrementally appending, or at shell exit).  So in that case having
SAVEHIST larger than HISTSIZE can be useful.

(These are details that didn't come up in an earlier zsh-workers
thread about default values for SAVEHIST and HISTSIZE and whether/when
it makes sense for them to differ.)




Messages sorted by: Reverse Date, Date, Thread, Author