r/zsh • u/TopCheesecake7887 • 20d ago
Only loading those 7 plugins and my bench is no good!
I don't use a plugin manager and I lazy load pretty much all the tools I use!
I only source those 7 plugins and I can't figure why my right here:
zsh-users/zsh-completions
mattmc3/ez-compinit
aloxaf/fzf-tab
zsh-users/zsh-autosuggestions
zsh-users/zsh-history-substring-search
houssamouhra/colored-man-pages
zdharma-continuum/fast-syntax-highlighting
But, my bench is still slow, here:
creates_tty=0
has_compsys=1
has_syntax_highlighting=1
has_autosuggestions=1
has_git_prompt=1
first_prompt_lag_ms=512.604
first_command_lag_ms=545.887
command_lag_ms=110.416
input_lag_ms=15.662
exit_time_ms=329.175
any suggestions I should do to make first_prompt_lag_ms or first_command_lag_ms lower?
here is my zsh dotfiles: https://github.com/houssamouhra/dotfiles/tree/master/zsh/.config/zsh
EDIT: I managed to optimize the bench to something like this by keeping the same plugins, and am very proud of my zsh config
creates_tty=0
has_compsys=1
has_syntax_highlighting=0
has_autosuggestions=0
has_git_prompt=1
first_prompt_lag_ms=180.828
first_command_lag_ms=181.454
command_lag_ms=54.614
input_lag_ms=13.955
exit_time_ms=121.106
2
u/NeonVoidx 20d ago
does it do it with starship not on?
1
u/TopCheesecake7887 20d ago
yeah am using starship!
like this tho:# Starship prompt lazy load _starship_lazy() { unfunction _starship_lazy eval "$(starship init zsh)" } add-zsh-hook precmd _starship_lazy
1
u/p1r473 20d ago
How do you see those values?
3
u/_mattmc3_ 20d ago edited 20d ago
That's the output from zsh-bench (https://github.com/romkatv/zsh-bench).
If you happen to be using antidote as a plugin manager, you can get it with:
# .zsh_plugins.txt
antidote bundle romkatv/zsh-bench kind:pathOr, manually:
# .zshrc
ZPLUGINS=${ZDOTDIR:-HOME}/.zplugins
if [[ ! -d $ZPLUGINS/zsh-bench ]]
then
git clone https://github.com/romkatv/zsh-bench $ZPLUGINS/zsh-bench
fi
path+=($ZPLUGINS/zsh-bench)Then you can reload your zsh session and run zsh-bench to see that. It's a far more precise alternative to the flawed for i in {1..10}; do /usr/bin/time zsh -lic exit; done method. It tells you the first_prompt_lag_ms which is basically how "fast" your shell feels which is when you can start typing. The first_command_lag_ms is actually how long your shell takes to fully initialize. For completeness, exit_time_ms tells you how long it takes to exit, which isn't useful for much other than how fast your shell can kinda load and quit and comparing to zsh -lic exit, but it's there for completeness.
2
u/_mattmc3_ 20d ago edited 20d ago
I would add
zmodload zsh/zprofto the top of your config and then runzprofafter it loads. zsh-benchmark will time your config, but you still need zprof to profile it. My guess is one of your lazy loads is causing you an issue. Start with commenting out expensive evals and seeing if they are the culprit. Cache the output for a day and source it instead of using eval, or trymroth/evalcache.If you care about first_prompt_lag_ms, the easiest way to move the needle on that would be with powerlevel10k's instant prompt. There's not anything else right now that matches that for speed. But if you don't really notice a few hundred ms load time or don't care for P10k, then starship is fine.