]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/checkout.c
checkout: stop expanding sparse indexes
authorDerrick Stolee <dstolee@microsoft.com>
Tue, 29 Jun 2021 02:13:06 +0000 (02:13 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Jul 2021 22:05:53 +0000 (15:05 -0700)
commit1ba5f45132f987e630497c09b74af687bf4f863b
treee91fc1466d15b4bdd8867a91010111b449bfb8bf
parentf934f1b47fb56d18b2b81d9288590e03e9a0ed23
checkout: stop expanding sparse indexes

Previous changes did the necessary improvements to unpack-trees.c and
diff-lib.c in order to modify a sparse index based on its comparision
with a tree. The only remaining work is to remove some
ensure_full_index() calls and add tests that verify that the index is
not expanded in our interesting cases. Include 'switch' and 'restore' in
these tests, as they share a base implementation with 'checkout'.

Here are the relevant performance results from
p2000-sparse-operations.sh:

Test                                     HEAD~1           HEAD
--------------------------------------------------------------------------------
2000.18: git checkout -f - (full-v3)     0.49(0.43+0.03)  0.47(0.39+0.05) -4.1%
2000.19: git checkout -f - (full-v4)     0.45(0.37+0.06)  0.42(0.37+0.05) -6.7%
2000.20: git checkout -f - (sparse-v3)   0.76(0.71+0.07)  0.04(0.03+0.04) -94.7%
2000.21: git checkout -f - (sparse-v4)   0.75(0.72+0.04)  0.05(0.06+0.04) -93.3%

It is important to compare the full index case to the sparse index case,
as the previous results for the sparse index were inflated by the index
expansion. For index v4, this is an 88% improvement.

On an internal repository with over two million paths at HEAD and a
sparse-checkout definition containing ~60,000 of those paths, 'git
checkout' went from 3.5s to 297ms with this change. The theoretical
optimum where only those ~60,000 paths exist was 275ms, so the extra
sparse directory entries contribute a 22ms overhead.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c
t/t1092-sparse-checkout-compatibility.sh