Debug and Optimize ZSH Loading Time

kinopyo avatar


$ /usr/bin/time zsh -i -c exit
1.40 real         0.19 user         0.17 sys

Whenever I open another tab / pane, my ZSH is perceivably slow. It takes 1.4 seconds to load.


zsh -xv

This will output screens of verbose messages. Pay attention at where it hangs, that's where things get slow.

(I even recorded the screen with QuickTime so I can go back and inspect... 😅)


For me it was the eval "$(rbenv init -)" command that hangs the flow. Removing that and run the benchmark again.

# eval "$(rbenv init -)"

Then it only takes 0.3 seconds to load, 80% boost! 🎉

$ /usr/bin/time zsh -i -c exit
0.30 real         0.10 user         0.07 sys

You can run rbenv init - to see what it does:

export PATH="~/.rbenv/shims:${PATH}"
export RBENV_SHELL=zsh
source '/usr/local/Cellar/rbenv/1.1.2/libexec/../completions/rbenv.zsh'
command rbenv rehash 2>/dev/null
rbenv() {
  local command
  if [ "$#" -gt 0 ]; then

  case "$command" in
    eval "$(rbenv "sh-$command" "[email protected]")";;
    command rbenv "$command" "[email protected]";;

I do put the shims to my PATH ,but I don't need the rest like command completions and rehash on loading time.

-eval "$(rbenv init -)"
+export PATH=~/.rbenv/shims:$PATH

Credit goes to 👍.

kinopyo avatar
Written By


Indoor enthusiast, web developer, and former hardcore RTS gamer. #parenting
Enjoyed the post?

Clap to support the author, help others find it, and make your opinion count.