The sixth batch
[git/gitster.git] / t / perf / p5332-multi-pack-reuse.sh
blob5c6c575d62c64b178118bd5993df3ec9de5d1956
1 #!/bin/sh
3 test_description='tests pack performance with multi-pack reuse'
5 . ./perf-lib.sh
6 . "${TEST_DIRECTORY}/perf/lib-pack.sh"
8 packdir=.git/objects/pack
10 test_perf_large_repo
12 find_pack () {
13 for idx in $packdir/pack-*.idx
15 if git show-index <$idx | grep -q "$1"
16 then
17 basename $idx
18 fi || return 1
19 done
22 repack_into_n_chunks () {
23 git repack -adk &&
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
38 done
40 # grab any remaining objects not packed by the previous step(s)
41 git pack-objects --revs --all --honor-pack-keep --delta-base-offset \
42 $packdir/pack &&
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
50 done
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 \
72 --stdout <in >result
75 test_size "clone size for $nr_packs-pack scenario ($reuse-pack reuse)" '
76 wc -c <result
78 done
79 done
81 test_done