Skip to content

Conversation

@Crysthamus
Copy link
Contributor

@Crysthamus Crysthamus commented Nov 22, 2025

Introduces compiling of cache files for faster startup times. Also changed the remove glob? to match both the init-.sh and init-.zwc files.

Closes #12 @mroth @acevif
With only eval

archlinux% hyperfine --warmup 3 --min-runs 10 "zsh -l -i -c exit"
Benchmark 1: zsh -l -i -c exit
  Time (mean ± σ):      64.6 ms ±   1.8 ms    [User: 42.9 ms, System: 25.9 ms]
  Range (min … max):    62.7 ms …  69.1 ms    44 runs

With evallcache

archlinux% hyperfine --warmup 3 --min-runs 10 "zsh -l -i -c exit"
Benchmark 1: zsh -l -i -c exit
  Time (mean ± σ):      58.5 ms ±   1.1 ms    [User: 40.7 ms, System: 24.0 ms]
  Range (min … max):    57.6 ms …  63.1 ms    48 runs

With zcompile

hyperfine --warmup 3 --min-runs 10 "zsh -l -i -c exit"
Benchmark 1: zsh -l -i -c exit
  Time (mean ± σ):      55.4 ms ±   1.8 ms    [User: 38.8 ms, System: 22.7 ms]
  Range (min … max):    53.9 ms …  61.4 ms    50 runs

Difference between no evallcache and evallcache is around 5.1ms, and difference between the one with zcompile and the one without is 3.7ms

I used the following .zshrc

ZINIT_HOME="${HOME}/.local/share/zinit/zinit.git"

if [ ! -d "$ZINIT_HOME" ]; then
   mkdir -p "$(dirname $ZINIT_HOME)"
   git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
fi

source "${ZINIT_HOME}/zinit.zsh"

zinit wait lucid for \
 atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay" \
    zdharma-continuum/fast-syntax-highlighting \
 blockf \
    zsh-users/zsh-completions \
 atload"!_zsh_autosuggest_start" \
    zsh-users/zsh-autosuggestions
zinit light Aloxaf/fzf-tab
zinit light mroth/evalcache

# Keybindings
bindkey -e
bindkey '^p' history-search-backward
bindkey '^n' history-search-forward
bindkey '^[w' kill-region

# History
HISTSIZE=5000
HISTFILE=~/.zsh_history
SAVEHIST=$HISTSIZE
HISTDUP=erase
setopt appendhistory
setopt sharehistory
setopt hist_ignore_space
setopt hist_ignore_all_dups
setopt hist_save_no_dups
setopt hist_ignore_dups
setopt hist_find_no_dups

# Completion styling
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
zstyle ':completion:*' menu no
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls --color $realpath'
zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'ls --color $realpath'

# Aliases
alias ls='ls --color'

# Evals
_evalcache fzf --zsh
_evalcache zoxide init --cmd cd zsh
_evalcache mise activate zsh

Introduces compiling of cache files for faster startup times. Also changed the remove glob? to match both the init-.sh and init-.zwc files.
@mroth
Copy link
Owner

mroth commented Nov 24, 2025

LGTM! Thank you for the contribution!

@mroth mroth merged commit d6973f8 into mroth:master Nov 24, 2025
@Crysthamus Crysthamus deleted the patch-1 branch November 25, 2025 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[idea] zcompile cache

2 participants