うならぼ

申し訳程度のアフィリエイトとか広告とか解析とかは/aboutを参照

shallow cloneが却って遅いケース

皆さんLinuxカーネルtorvalds/linux)をcloneしてますか?私はしてません。

そういう時に便利といわれる git clone --depth=1 もとい shallow clone。確かにばかでかいリポジトリには便利です。

$ time git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/torva lds/linux/
Cloning into 'linux'...
remote: Sending approximately 766.11 MiB ...
remote: Counting objects: 84441, done
remote: Finding sources: 100% (7185/7185)
remote: Total 4053549 (delta 3399224), reused 4052847 (delta 3399224)
Receiving objects: 100% (4053549/4053549), 787.54 MiB | 21.85 MiB/s, done.
Resolving deltas: 100% (3399285/3399285), done.
Checking connectivity... done.
Checking out files: 100% (48957/48957), done.

real    7m27.981s
user    0m0.000s
sys     0m0.000s

$ du -sh
1.5G    .

$ rm -rf linux

$ time git clone --depth=1 https://kernel.googlesource.com/pub/scm/linux/kernel /git/torvalds/linux/
Cloning into 'linux'...
remote: Sending approximately 766.11 MiB ...
remote: Counting objects: 53422, done
remote: Finding sources: 100% (53422/53422)
remote: Total 53422 (delta 3577), reused 15764 (delta 3577)
Receiving objects: 100% (53422/53422), 142.66 MiB | 4.55 MiB/s, done.
Resolving deltas: 100% (3577/3577), done.
Checking connectivity... done.
Checking out files: 100% (48957/48957), done.

real    2m1.486s
user    0m0.015s
sys     0m0.000s

$ du -sh
714M    .

msysgitやっぱり遅いよなあ。

もうひとつ例を見てみましょう。

$ time git clone https://github.com/unarist/gentoojp-flyer.git
Cloning into 'gentoojp-flyer'...
remote: Counting objects: 44, done.
remote: Total 44 (delta 0), reused 0 (delta 0), pack-reused 44
Unpacking objects: 100% (44/44), done.
Checking connectivity... done.

real    0m4.765s
user    0m0.000s
sys     0m0.015s

$ du -sh gentoojp-flyer/
25M     gentoojp-flyer/

$ rm -rf gentoojp-flyer

$ time git clone --depth=1 https://github.com/unarist/gentoojp-flyer.git
Cloning into 'gentoojp-flyer'...
remote: Counting objects: 17, done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 17 (delta 1), reused 17 (delta 1), pack-reused 0
Unpacking objects: 100% (17/17), done.
Checking connectivity... done.

real    0m6.635s
user    0m0.015s
sys     0m0.000s

$ du -sh gentoojp-flyer/
19M     gentoojp-flyer/

むしろ遅くなってますね。pack-reused 44 の前者の時はあっという間に受信が始まったのに、後者の時はCompressingで時間を取られてたので、必要な分だけpackしなおすのに時間がかかったのかなーと。

でもGoogleSourceの時はそもそもpack-reusedって表示がなくて、これはGithubの独自拡張なんだろうか・・・。