Skip to content

Commit fbf20ae

Browse files
peffgitster
authored andcommitted
p5303: measure time to repack with keep
Add two new tests to measure repack performance. Both tests split the repository into synthetic "pushes", and then leave the remaining objects in a big base pack. The first new test marks an empty pack as "kept" and then passes --honor-pack-keep to avoid including objects in it. That doesn't change the resulting pack, but it does let us compare to the normal repack case to see how much overhead we add to check whether objects are kept or not. The other test is of --stdin-packs, which gives us a sense of how that number scales based on the number of packs we provide as input. In each of those tests, the empty pack isn't considered, but the residual pack (objects that were left over and not included in one of the synthetic push packs) is marked as kept. (Note that in the single-pack case of the --stdin-packs test, there is nothing do since there are no non-excluded packs). Here are some timings on a recent clone of the kernel: 5303.5: repack (1) 57.26(54.59+10.84) 5303.6: repack with kept (1) 57.33(54.80+10.51) in the 50-pack case, things start to slow down: 5303.11: repack (50) 71.54(88.57+4.84) 5303.12: repack with kept (50) 85.12(102.05+4.94) and by the time we hit 1,000 packs, things are substantially worse, even though the resulting pack produced is the same: 5303.17: repack (1000) 216.87(490.79+14.57) 5303.18: repack with kept (1000) 665.63(938.87+15.76) That's because the code paths around handling .keep files are known to scale badly; they look in every single pack file to find each object. Our solution to that was to notice that most repos don't have keep files, and to make that case a fast path. But as soon as you add a single .keep, that part of pack-objects slows down again (even if we have fewer objects total to look at). Likewise, the scaling is pretty extreme on --stdin-packs (but each subsequent test is also being asked to do more work): 5303.7: repack with --stdin-packs (1) 0.01(0.01+0.00) 5303.13: repack with --stdin-packs (50) 3.53(12.07+0.24) 5303.19: repack with --stdin-packs (1000) 195.83(371.82+8.10) Signed-off-by: Jeff King <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 60bb5f2 commit fbf20ae

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

t/perf/p5303-many-packs.sh

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,15 @@ repack_into_n () {
3131
' "$1" >pushes &&
3232

3333
# create base packfile
34-
head -n 1 pushes |
35-
git pack-objects --delta-base-offset --revs staging/pack &&
34+
base_pack=$(
35+
head -n 1 pushes |
36+
git pack-objects --delta-base-offset --revs staging/pack
37+
) &&
38+
test_export base_pack &&
39+
40+
# create an empty packfile
41+
empty_pack=$(git pack-objects staging/pack </dev/null) &&
42+
test_export empty_pack &&
3643

3744
# and then incrementals between each pair of commits
3845
last= &&
@@ -49,6 +56,12 @@ repack_into_n () {
4956
last=$rev
5057
done <pushes &&
5158

59+
(
60+
find staging -type f -name 'pack-*.pack' |
61+
xargs -n 1 basename | grep -v "$base_pack" &&
62+
printf "^pack-%s.pack\n" $base_pack
63+
) >stdin.packs
64+
5265
# and install the whole thing
5366
rm -f .git/objects/pack/* &&
5467
mv staging/* .git/objects/pack/
@@ -91,6 +104,23 @@ do
91104
--reflog --indexed-objects --delta-base-offset \
92105
--stdout </dev/null >/dev/null
93106
'
107+
108+
test_perf "repack with kept ($nr_packs)" '
109+
git pack-objects --keep-true-parents \
110+
--keep-pack=pack-$empty_pack.pack \
111+
--honor-pack-keep --non-empty --all \
112+
--reflog --indexed-objects --delta-base-offset \
113+
--stdout </dev/null >/dev/null
114+
'
115+
116+
test_perf "repack with --stdin-packs ($nr_packs)" '
117+
git pack-objects \
118+
--keep-true-parents \
119+
--stdin-packs \
120+
--non-empty \
121+
--delta-base-offset \
122+
--stdout <stdin.packs >/dev/null
123+
'
94124
done
95125

96126
# Measure pack loading with 10,000 packs.

0 commit comments

Comments
 (0)