bitmap-lookup-table: add performance tests for lookup table

Add performance tests to verify the performance of lookup table. `p5310-pack-bitmaps.sh` contain tests with and without lookup table. `p5312-pack-bitmaps-revs.sh` contain same tests with and without lookup table but with `pack.writeReverseIndex` enabled. Lookup table makes Git run faster in most of the cases. Below is the result of `t/perf/p5310-pack-bitmaps.sh`.`perf/p5326-multi-pack-bitmaps.sh` gives similar result. The repository used in the test is linux kernel. Test this tree ----------------------------------------------------------------------- 5310.4: enable lookup table: false 0.01(0.00+0.00) 5310.5: repack to disk 320.89(230.20+23.45) 5310.6: simulated clone 14.04(5.78+1.79) 5310.7: simulated fetch 1.95(3.05+0.20) 5310.8: pack to file (bitmap) 44.73(20.55+7.45) 5310.9: rev-list (commits) 0.78(0.46+0.10) 5310.10: rev-list (objects) 4.07(3.97+0.08) 5310.11: rev-list with tag negated via --not 0.06(0.02+0.03) --all (objects) 5310.12: rev-list with negative tag (objects) 0.21(0.15+0.05) 5310.13: rev-list count with blob:none 0.24(0.17+0.06) 5310.14: rev-list count with blob:limit=1k 7.07(5.92+0.48) 5310.15: rev-list count with tree:0 0.25(0.17+0.07) 5310.16: simulated partial clone 5.67(3.28+0.64) 5310.18: clone (partial bitmap) 16.05(8.34+1.86) 5310.19: pack to file (partial bitmap) 59.76(27.22+7.43) 5310.20: rev-list with tree filter (partial bitmap) 0.90(0.18+0.16) 5310.24: enable lookup table: true 0.01(0.00+0.00) 5310.25: repack to disk 319.73(229.30+23.01) 5310.26: simulated clone 13.69(5.72+1.78) 5310.27: simulated fetch 1.84(3.02+0.16) 5310.28: pack to file (bitmap) 45.63(20.67+7.50) 5310.29: rev-list (commits) 0.56(0.39+0.8) 5310.30: rev-list (objects) 3.77(3.74+0.08) 5310.31: rev-list with tag negated via --not 0.05(0.02+0.03) --all (objects) 5310.32: rev-list with negative tag (objects) 0.21(0.15+0.05) 5310.33: rev-list count with blob:none 0.23(0.17+0.05) 5310.34: rev-list count with blob:limit=1k 6.65(5.72+0.40) 5310.35: rev-list count with tree:0 0.23(0.16+0.06) 5310.36: simulated partial clone 5.57(3.26+0.59) 5310.38: clone (partial bitmap) 15.89(8.39+1.84) 5310.39: pack to file (partial bitmap) 58.32(27.55+7.47) 5310.40: rev-list with tree filter (partial bitmap) 0.73(0.18+0.15) Test 4-15 are tested without using lookup table. Same tests are repeated in 16-30 (using lookup table). Mentored-by: Taylor Blau <me@ttaylorr.com> Co-Mentored-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com> Signed-off-by: Abhradeep Chakraborty <chakrabortyabhradeep79@gmail.com> Reviewed-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Abhradeep Chakraborty committed Aug 14, 2022 at 16:55 UTC 761416ef91d819d84a11222ec5bc3cbc66d3ddac
5 files changed +199 -122
t/perf/lib-bitmap.sh
+31
@@ -67,3 +67,34 @@ test_partial_bitmap () {
67 --filter=tree:0 >/dev/null
68 '
69 }
70 +
71 +test_pack_bitmap () {
72 + test_perf "repack to disk" '
73 + git repack -ad
74 + '
75 +
76 + test_full_bitmap
77 +
78 + test_expect_success "create partial bitmap state" '
79 + # pick a commit to represent the repo tip in the past
80 + cutoff=$(git rev-list HEAD~100 -1) &&
81 + orig_tip=$(git rev-parse HEAD) &&
82 +
83 + # now kill off all of the refs and pretend we had
84 + # just the one tip
85 + rm -rf .git/logs .git/refs/* .git/packed-refs &&
86 + git update-ref HEAD $cutoff &&
87 +
88 + # and then repack, which will leave us with a nice
89 + # big bitmap pack of the "old" history, and all of
90 + # the new history will be loose, as if it had been pushed
91 + # up incrementally and exploded via unpack-objects
92 + git repack -Ad &&
93 +
94 + # and now restore our original tip, as if the pushes
95 + # had happened
96 + git update-ref HEAD $orig_tip
97 + '
98 +
99 + test_partial_bitmap
100 +}
t/perf/p5310-pack-bitmaps.sh
+32 -46
@@ -4,51 +4,37 @@ test_description='Tests pack performance using bitmaps'
4 . ./perf-lib.sh
5 . "${TEST_DIRECTORY}/perf/lib-bitmap.sh"
6
7 -test_perf_large_repo
8 -
9 -# note that we do everything through config,
10 -# since we want to be able to compare bitmap-aware
11 -# git versus non-bitmap git
12 -#
13 -# We intentionally use the deprecated pack.writebitmaps
14 -# config so that we can test against older versions of git.
15 -test_expect_success 'setup bitmap config' '
16 - git config pack.writebitmaps true
17 -'
18 -
19 -# we need to create the tag up front such that it is covered by the repack and
20 -# thus by generated bitmaps.
21 -test_expect_success 'create tags' '
22 - git tag --message="tag pointing to HEAD" perf-tag HEAD
23 -'
24 -
25 -test_perf 'repack to disk' '
26 - git repack -ad
27 -'
28 -
29 -test_full_bitmap
30 -
31 -test_expect_success 'create partial bitmap state' '
32 - # pick a commit to represent the repo tip in the past
33 - cutoff=$(git rev-list HEAD~100 -1) &&
34 - orig_tip=$(git rev-parse HEAD) &&
35 -
36 - # now kill off all of the refs and pretend we had
37 - # just the one tip
38 - rm -rf .git/logs .git/refs/* .git/packed-refs &&
39 - git update-ref HEAD $cutoff &&
40 -
41 - # and then repack, which will leave us with a nice
42 - # big bitmap pack of the "old" history, and all of
43 - # the new history will be loose, as if it had been pushed
44 - # up incrementally and exploded via unpack-objects
45 - git repack -Ad &&
46 -
47 - # and now restore our original tip, as if the pushes
48 - # had happened
49 - git update-ref HEAD $orig_tip
50 -'
51 -
52 -test_partial_bitmap
7 +test_lookup_pack_bitmap () {
8 + test_expect_success 'start the test from scratch' '
9 + rm -rf * .git
10 + '
11 +
12 + test_perf_large_repo
13 +
14 + # note that we do everything through config,
15 + # since we want to be able to compare bitmap-aware
16 + # git versus non-bitmap git
17 + #
18 + # We intentionally use the deprecated pack.writebitmaps
19 + # config so that we can test against older versions of git.
20 + test_expect_success 'setup bitmap config' '
21 + git config pack.writebitmaps true
22 + '
23 +
24 + # we need to create the tag up front such that it is covered by the repack and
25 + # thus by generated bitmaps.
26 + test_expect_success 'create tags' '
27 + git tag --message="tag pointing to HEAD" perf-tag HEAD
28 + '
29 +
30 + test_perf "enable lookup table: $1" '
31 + git config pack.writeBitmapLookupTable '"$1"'
32 + '
33 +
34 + test_pack_bitmap
35 +}
36 +
37 +test_lookup_pack_bitmap false
38 +test_lookup_pack_bitmap true
39
40 test_done
t/perf/p5311-pack-bitmaps-fetch.sh
+42 -32
@@ -3,42 +3,52 @@
3 test_description='performance of fetches from bitmapped packs'
4 . ./perf-lib.sh
5
6 -test_perf_default_repo
7 -
8 -test_expect_success 'create bitmapped server repo' '
9 - git config pack.writebitmaps true &&
10 - git repack -ad
11 -'
12 -
13 -# simulate a fetch from a repository that last fetched N days ago, for
14 -# various values of N. We do so by following the first-parent chain,
15 -# and assume the first entry in the chain that is N days older than the current
16 -# HEAD is where the HEAD would have been then.
17 -for days in 1 2 4 8 16 32 64 128; do
18 - title=$(printf '%10s' "($days days)")
19 - test_expect_success "setup revs from $days days ago" '
20 - now=$(git log -1 --format=%ct HEAD) &&
21 - then=$(($now - ($days * 86400))) &&
22 - tip=$(git rev-list -1 --first-parent --until=$then HEAD) &&
23 - {
24 - echo HEAD &&
25 - echo ^$tip
26 - } >revs
6 +test_fetch_bitmaps () {
7 + test_expect_success 'setup test directory' '
8 + rm -fr * .git
9 '
10
29 - test_perf "server $title" '
30 - git pack-objects --stdout --revs \
31 - --thin --delta-base-offset \
32 - <revs >tmp.pack
33 - '
11 + test_perf_default_repo
12
35 - test_size "size $title" '
36 - wc -c <tmp.pack
13 + test_expect_success 'create bitmapped server repo' '
14 + git config pack.writebitmaps true &&
15 + git config pack.writeBitmapLookupTable '"$1"' &&
16 + git repack -ad
17 '
18
39 - test_perf "client $title" '
40 - git index-pack --stdin --fix-thin <tmp.pack
41 - '
42 -done
19 + # simulate a fetch from a repository that last fetched N days ago, for
20 + # various values of N. We do so by following the first-parent chain,
21 + # and assume the first entry in the chain that is N days older than the current
22 + # HEAD is where the HEAD would have been then.
23 + for days in 1 2 4 8 16 32 64 128; do
24 + title=$(printf '%10s' "($days days)")
25 + test_expect_success "setup revs from $days days ago" '
26 + now=$(git log -1 --format=%ct HEAD) &&
27 + then=$(($now - ($days * 86400))) &&
28 + tip=$(git rev-list -1 --first-parent --until=$then HEAD) &&
29 + {
30 + echo HEAD &&
31 + echo ^$tip
32 + } >revs
33 + '
34 +
35 + test_perf "server $title (lookup=$1)" '
36 + git pack-objects --stdout --revs \
37 + --thin --delta-base-offset \
38 + <revs >tmp.pack
39 + '
40 +
41 + test_size "size $title" '
42 + wc -c <tmp.pack
43 + '
44 +
45 + test_perf "client $title (lookup=$1)" '
46 + git index-pack --stdin --fix-thin <tmp.pack
47 + '
48 + done
49 +}
50 +
51 +test_fetch_bitmaps true
52 +test_fetch_bitmaps false
53
54 test_done
t/perf/p5312-pack-bitmaps-revs.sh new
+35
@@ -0,0 +1,35 @@
1 +#!/bin/sh
2 +
3 +test_description='Tests pack performance using bitmaps (rev index enabled)'
4 +. ./perf-lib.sh
5 +. "${TEST_DIRECTORY}/perf/lib-bitmap.sh"
6 +
7 +test_lookup_pack_bitmap () {
8 + test_expect_success 'start the test from scratch' '
9 + rm -rf * .git
10 + '
11 +
12 + test_perf_large_repo
13 +
14 + test_expect_success 'setup bitmap config' '
15 + git config pack.writebitmaps true &&
16 + git config pack.writeReverseIndex true
17 + '
18 +
19 + # we need to create the tag up front such that it is covered by the repack and
20 + # thus by generated bitmaps.
21 + test_expect_success 'create tags' '
22 + git tag --message="tag pointing to HEAD" perf-tag HEAD
23 + '
24 +
25 + test_perf "enable lookup table: $1" '
26 + git config pack.writeBitmapLookupTable '"$1"'
27 + '
28 +
29 + test_pack_bitmap
30 +}
31 +
32 +test_lookup_pack_bitmap false
33 +test_lookup_pack_bitmap true
34 +
35 +test_done
t/perf/p5326-multi-pack-bitmaps.sh
+59 -44
@@ -4,49 +4,64 @@ test_description='Tests performance using midx bitmaps'
4 . ./perf-lib.sh
5 . "${TEST_DIRECTORY}/perf/lib-bitmap.sh"
6
7 -test_perf_large_repo
8 -
9 -# we need to create the tag up front such that it is covered by the repack and
10 -# thus by generated bitmaps.
11 -test_expect_success 'create tags' '
12 - git tag --message="tag pointing to HEAD" perf-tag HEAD
13 -'
14 -
15 -test_expect_success 'start with bitmapped pack' '
16 - git repack -adb
17 -'
18 -
19 -test_perf 'setup multi-pack index' '
20 - git multi-pack-index write --bitmap
21 -'
22 -
23 -test_expect_success 'drop pack bitmap' '
24 - rm -f .git/objects/pack/pack-*.bitmap
25 -'
26 -
27 -test_full_bitmap
28 -
29 -test_expect_success 'create partial bitmap state' '
30 - # pick a commit to represent the repo tip in the past
31 - cutoff=$(git rev-list HEAD~100 -1) &&
32 - orig_tip=$(git rev-parse HEAD) &&
33 -
34 - # now pretend we have just one tip
35 - rm -rf .git/logs .git/refs/* .git/packed-refs &&
36 - git update-ref HEAD $cutoff &&
37 -
38 - # and then repack, which will leave us with a nice
39 - # big bitmap pack of the "old" history, and all of
40 - # the new history will be loose, as if it had been pushed
41 - # up incrementally and exploded via unpack-objects
42 - git repack -Ad &&
43 - git multi-pack-index write --bitmap &&
44 -
45 - # and now restore our original tip, as if the pushes
46 - # had happened
47 - git update-ref HEAD $orig_tip
48 -'
49 -
50 -test_partial_bitmap
7 +test_bitmap () {
8 + local enabled="$1"
9 +
10 + test_expect_success "remove existing repo (lookup=$enabled)" '
11 + rm -fr * .git
12 + '
13 +
14 + test_perf_large_repo
15 +
16 + # we need to create the tag up front such that it is covered by the repack and
17 + # thus by generated bitmaps.
18 + test_expect_success 'create tags' '
19 + git tag --message="tag pointing to HEAD" perf-tag HEAD
20 + '
21 +
22 + test_expect_success "use lookup table: $enabled" '
23 + git config pack.writeBitmapLookupTable '"$enabled"'
24 + '
25 +
26 + test_expect_success "start with bitmapped pack (lookup=$enabled)" '
27 + git repack -adb
28 + '
29 +
30 + test_perf "setup multi-pack index (lookup=$enabled)" '
31 + git multi-pack-index write --bitmap
32 + '
33 +
34 + test_expect_success "drop pack bitmap (lookup=$enabled)" '
35 + rm -f .git/objects/pack/pack-*.bitmap
36 + '
37 +
38 + test_full_bitmap
39 +
40 + test_expect_success "create partial bitmap state (lookup=$enabled)" '
41 + # pick a commit to represent the repo tip in the past
42 + cutoff=$(git rev-list HEAD~100 -1) &&
43 + orig_tip=$(git rev-parse HEAD) &&
44 +
45 + # now pretend we have just one tip
46 + rm -rf .git/logs .git/refs/* .git/packed-refs &&
47 + git update-ref HEAD $cutoff &&
48 +
49 + # and then repack, which will leave us with a nice
50 + # big bitmap pack of the "old" history, and all of
51 + # the new history will be loose, as if it had been pushed
52 + # up incrementally and exploded via unpack-objects
53 + git repack -Ad &&
54 + git multi-pack-index write --bitmap &&
55 +
56 + # and now restore our original tip, as if the pushes
57 + # had happened
58 + git update-ref HEAD $orig_tip
59 + '
60 +
61 + test_partial_bitmap
62 +}
63 +
64 +test_bitmap false
65 +test_bitmap true
66
67 test_done