600000007

プログラムと折り紙のブログです。

screen上でのvimの起動が遅い

最近screen上でvimを使っているのだけど、起動が遅いなあと思って色々調べてみた。

環境は以下の通り。

OS:Solaris 10 11/06 32bit
vim:VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jan 5 2011 16:24:44)
screen:Screen version 4.00.03 (FAU) 23-Oct-06


vimの起動時間は--startuptimeオプションで調べられるらしい。
Vim 7.2.269 以降で使用できるオプション。

実行結果は、

000.076 000.076: --- VIM STARTING ---
000.225 000.149: Allocated generic buffers
001.063 000.838: locale set
001.095 000.032: GUI prepared
001.100 000.005: clipboard setup
001.130 000.030: window checked
002.010 000.880: inits 1
002.017 000.007: parsing arguments
002.018 000.001: expanding arguments
002.133 000.115: shell init
002.759 000.626: Termcap init
002.842 000.083: inits 2
003.060 000.218: init highlight
003.327 000.052 000.052: sourcing $HOME/.vimrc
003.339 000.227: sourcing vimrc file(s)
004.045 000.203 000.203: sourcing /usr/local/share/vim/vim73/plugin/getscriptPlugin.vim
004.401 000.309 000.309: sourcing /usr/local/share/vim/vim73/plugin/gzip.vim
004.798 000.357 000.357: sourcing /usr/local/share/vim/vim73/plugin/matchparen.vim
005.881 001.041 001.041: sourcing /usr/local/share/vim/vim73/plugin/netrwPlugin.vim
005.986 000.065 000.065: sourcing /usr/local/share/vim/vim73/plugin/rrhelper.vim
006.068 000.046 000.046: sourcing /usr/local/share/vim/vim73/plugin/spellfile.vim
006.369 000.265 000.265: sourcing /usr/local/share/vim/vim73/plugin/tarPlugin.vim
006.496 000.089 000.089: sourcing /usr/local/share/vim/vim73/plugin/tohtml.vim
006.790 000.257 000.257: sourcing /usr/local/share/vim/vim73/plugin/vimballPlugin.vim
007.013 000.183 000.183: sourcing /usr/local/share/vim/vim73/plugin/zipPlugin.vim
007.056 000.902: loading plugins
007.088 000.032: inits 3
007.206 000.118: reading viminfo
6063.584 6056.378: setup clipboard
6063.645 000.061: setting raw mode
6063.691 000.046: start termcap
6063.725 000.034: clearing screen
6063.946 000.221: opening buffers
6064.074 000.128: BufEnter autocommands
6064.076 000.002: editing files in windows
6064.200 000.124: VimEnter autocommands
6064.201 000.001: before starting main loop
6065.125 000.924: first screen update
6065.127 000.002: --- VIM STARTED ---

起動に6秒も掛かってたのか。そりゃ遅いわ。
ボトルネックになってるのは、

6063.584 6056.378: setup clipboard

クリップボードのセットアップ処理らしい。
クリップボードが関連するのはOSとscreen。
というわけでscreen上ではなくshellから直接vimを起動してみる。

000.075 000.075: --- VIM STARTING ---
000.231 000.156: Allocated generic buffers
001.047 000.816: locale set
001.080 000.033: GUI prepared
001.085 000.005: clipboard setup
001.120 000.035: window checked
002.052 000.932: inits 1
002.060 000.008: parsing arguments
002.062 000.002: expanding arguments
002.177 000.115: shell init
002.829 000.652: Termcap init
002.915 000.086: inits 2
003.128 000.213: init highlight
003.415 000.059 000.059: sourcing $HOME/.vimrc
003.427 000.240: sourcing vimrc file(s)
004.110 000.211 000.211: sourcing /usr/local/share/vim/vim73/plugin/getscriptPlugin.vim
004.463 000.314 000.314: sourcing /usr/local/share/vim/vim73/plugin/gzip.vim
004.864 000.361 000.361: sourcing /usr/local/share/vim/vim73/plugin/matchparen.vim
005.955 001.048 001.048: sourcing /usr/local/share/vim/vim73/plugin/netrwPlugin.vim
006.072 000.077 000.077: sourcing /usr/local/share/vim/vim73/plugin/rrhelper.vim
006.157 000.048 000.048: sourcing /usr/local/share/vim/vim73/plugin/spellfile.vim
006.454 000.261 000.261: sourcing /usr/local/share/vim/vim73/plugin/tarPlugin.vim
006.580 000.087 000.087: sourcing /usr/local/share/vim/vim73/plugin/tohtml.vim
006.866 000.248 000.248: sourcing /usr/local/share/vim/vim73/plugin/vimballPlugin.vim
007.104 000.200 000.200: sourcing /usr/local/share/vim/vim73/plugin/zipPlugin.vim
007.157 000.875: loading plugins
007.189 000.032: inits 3
007.257 000.068: reading viminfo
948.738 941.481: setup clipboard
948.809 000.071: setting raw mode
948.857 000.048: start termcap
948.891 000.034: clearing screen
949.109 000.218: opening buffers
949.268 000.159: BufEnter autocommands
949.272 000.004: editing files in windows
949.413 000.141: VimEnter autocommands
949.415 000.002: before starting main loop
950.352 000.937: first screen update
950.354 000.002: --- VIM STARTED ---

はええ。
やっぱscreenが関係していたのね。
ということで2〜3週間は8窓で起動しっぱなしだったscreenプロセスを再起動してみた。
すると、

000.072 000.072: --- VIM STARTING ---
000.221 000.149: Allocated generic buffers
001.027 000.806: locale set
001.059 000.032: GUI prepared
001.064 000.005: clipboard setup
001.094 000.030: window checked
001.988 000.894: inits 1
001.995 000.007: parsing arguments
001.996 000.001: expanding arguments
002.108 000.112: shell init
002.783 000.675: Termcap init
002.867 000.084: inits 2
003.085 000.218: init highlight
003.342 000.041 000.041: sourcing $HOME/.vimrc
003.354 000.228: sourcing vimrc file(s)
004.010 000.200 000.200: sourcing /usr/local/share/vim/vim73/plugin/getscriptPlugin.vim
004.360 000.303 000.303: sourcing /usr/local/share/vim/vim73/plugin/gzip.vim
004.751 000.351 000.351: sourcing /usr/local/share/vim/vim73/plugin/matchparen.vim
005.827 001.033 001.033: sourcing /usr/local/share/vim/vim73/plugin/netrwPlugin.vim
005.931 000.065 000.065: sourcing /usr/local/share/vim/vim73/plugin/rrhelper.vim
006.012 000.046 000.046: sourcing /usr/local/share/vim/vim73/plugin/spellfile.vim
006.312 000.264 000.264: sourcing /usr/local/share/vim/vim73/plugin/tarPlugin.vim
006.439 000.089 000.089: sourcing /usr/local/share/vim/vim73/plugin/tohtml.vim
006.733 000.257 000.257: sourcing /usr/local/share/vim/vim73/plugin/vimballPlugin.vim
006.956 000.183 000.183: sourcing /usr/local/share/vim/vim73/plugin/zipPlugin.vim
006.999 000.854: loading plugins
007.032 000.033: inits 3
007.225 000.193: reading viminfo
1108.732 1101.507: setup clipboard
1108.801 000.069: setting raw mode
1108.845 000.044: start termcap
1108.886 000.041: clearing screen
1109.136 000.250: opening buffers
1109.276 000.140: BufEnter autocommands
1109.280 000.004: editing files in windows
1109.421 000.141: VimEnter autocommands
1109.423 000.002: before starting main loop
1110.493 001.070: first screen update
1110.499 000.006: --- VIM STARTED ---

shellからの起動とほぼ変わらないスピードになりました。
screenの仕組み上、長く使用しているとクリップボードが重たくなるのでしょうか?
そこらへん設定で上限を設けたり出来そうですね。