LoginSignup
15
13

More than 5 years have passed since last update.

巨大なGitリポジトリでのGitコマンドを速くする

Last updated at Posted at 2017-03-11

最近ワケあってブラウザのソースコードをいくつか読んでいたのだけど、いかんせんどれもファイル数が多いため、ターミナル上で実行する操作1つ1つが遅くて非常にストレスフルだった。ディスクのI/Oがボトルネックになっているようで、ファイルシステムのvnode数を上げることでチューニングが出来るらしい。kern.maxvodeというカーネルパラメータがこの設定にあたる。

$ sudo sysctl kern.maxvnodes=$((512*1024))

でmaxvodeを変更し、$ git statusの実行時間を比較してみる。なお、kern.maxvodeの現在の値は

$ sysctl -a | egrep kern.maxvnodes

で確認できる。筆者が利用しているのはmacOSだが、BSD系の環境だとkern.maxvnodeのデフォルトは263168のようだ。

BEFORE

kern.maxvnodes = 263168

  • 0.86s user 4.71s system 222% cpu 2.504 total
  • 0.88s user 3.91s system 208% cpu 2.305 total
  • 0.85s user 5.35s system 241% cpu 2.569 total

=> AVG: 2.45s

AFTER

kern.maxvnodes = 524288

  • 0.87s user 2.92s system 184% cpu 2.053 total
  • 0.84s user 1.39s system 152% cpu 1.463 total
  • 0.87s user 1.37s system 155% cpu 1.435 total

=> AVG: 1.64s

平均で1秒ほど速くなった。1回目の実行が他と比べて遅いのは、ディスクI/O系のカーネルパラメータの変更が実際に効果が現れるまでには多少時間がかかるということだろうか。ちなみに、kern.maxvnodesをこれ以上あげても特に変化は見られなかった。またほかのコマンドでも改善は見られるようだが、特に差が顕著だったのが$ git statusだった。

参考

15
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
15
13