LoginSignup
11
13

More than 5 years have passed since last update.

zshのプラグインマネージャーを外したら10倍以上起動が高速化した話

Last updated at Posted at 2016-08-21

問題

zshのプラグインマネージャーにantigenを使っていました。
が、いつの間にか信じられないぐらい起動が遅くなっていました。

解決

ghqによってプラグインをインストールし、zshrcではsourceするだけの方式を採用しました。

GHQ=$HOME/src/github.com
source $GHQ/robbyrussell/oh-my-zsh/lib/completion.zsh
source $GHQ/rupa/z/z.sh
source $GHQ/zsh-users/zsh-autosuggestions/zsh-autosuggestions.zsh
source $GHQ/zsh-users/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

zshのプラグインなんて山のように入れてるわけではないので、起動を遅くするだけのプラグインマネージャーの出番は不要というわけです。いわゆるそれghqでいいよね案件です。

ghqについては、ghqを使ったローカルリポジトリの統一的・効率的な管理について - Kentaro Kuribayashi's blogが素晴らしくまとまっているので参照してください。

計測

さて、どのくらい高速化したかというと。

$ time ( zsh -i -c exit )
( zsh -i -c exit; )  1.45s user 0.80s system 103% cpu 2.175 total

$ time ( zsh -i -c exit )
( zsh -i -c exit; )  1.48s user 0.82s system 102% cpu 2.242 total

$ time ( zsh -i -c exit )
( zsh -i -c exit; )  1.46s user 0.82s system 103% cpu 2.204 total

$ time ( zsh -i -c exit )
( zsh -i -c exit; )  0.09s user 0.09s system 99% cpu 0.186 total

$ time ( zsh -i -c exit )
( zsh -i -c exit; )  0.10s user 0.09s system 97% cpu 0.195 total

$ time ( zsh -i -c exit )
( zsh -i -c exit; )  0.09s user 0.09s system 100% cpu 0.181 total

起動時間が0.2秒を切るぐらいになり、だいたい11倍くらい高速化しました。

終わりに

なんとなくイケてるからとプラグインマネージャーを使っていましが、トレードオフをちゃんと考える必要がありますね。

参考

11
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
13