3 test_description
='tests pack performance with multi-pack reuse'
6 .
"${TEST_DIRECTORY}/perf/lib-pack.sh"
8 packdir
=.git
/objects
/pack
13 for idx
in $packdir/pack-
*.idx
15 if git show-index
<$idx |
grep -q "$1"
22 repack_into_n_chunks
() {
25 test "$1" -eq 1 && return ||
27 find $packdir -type f |
sort >packs.before
&&
29 # partition the repository into $1 chunks of consecutive commits, and
30 # then create $1 packs with the objects reachable from each chunk
31 # (excluding any objects reachable from the previous chunks)
32 sz
="$(($(git rev-list --count --all) / $1))"
33 for rev in $
(git rev-list
--all |
awk "NR % $sz == 0" |
tac)
35 pack
="$(echo "$rev" | git pack-objects --revs \
36 --honor-pack-keep --delta-base-offset $packdir/pack)" &&
37 touch $packdir/pack-
$pack.keep ||
return 1
40 # grab any remaining objects not packed by the previous step(s)
41 git pack-objects
--revs --all --honor-pack-keep --delta-base-offset \
44 find $packdir -type f |
sort >packs.after
&&
46 # and install the whole thing
47 for f
in $
(comm -12 packs.before packs.after
)
49 rm -f "$f" ||
return 1
51 rm -fr $packdir/*.keep
54 for nr_packs
in 1 10 100
56 test_expect_success
"create $nr_packs-pack scenario" '
57 repack_into_n_chunks $nr_packs
60 test_expect_success
"setup bitmaps for $nr_packs-pack scenario" '
61 find $packdir -type f -name "*.idx" | sed -e "s/.*\/\(.*\)$/+\1/g" |
62 git multi-pack-index write --stdin-packs --bitmap \
63 --preferred-pack="$(find_pack $(git rev-parse HEAD))"
66 for reuse
in single multi
68 test_perf
"clone for $nr_packs-pack scenario ($reuse-pack reuse)" "
69 git for-each-ref --format='%(objectname)' refs/heads refs/tags >in &&
70 git -c pack.allowPackReuse=$reuse pack-objects \
71 --revs --delta-base-offset --use-bitmap-index \
75 test_size
"clone size for $nr_packs-pack scenario ($reuse-pack reuse)" '